Debian Codegraph @

src/dstack.cpp

raw symbols SCIP
1 // $Id: dstack.cpp,v 1.4 2003/04/14 05:51:03 mbridak Exp $cxx . . $ `<file>/src/dstack.cpp`/
2 // Simple Stack Class
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include "dstack.h"cxx . . $ `<file>/src/dstack.h`/
7
8 DStackcxx . . $ DStack#::DStackcxx . . $ DStack#DStack(49f6e7a06ebc5aa8).()
9 {
10 bottom_cxx . . $ DStack#bottom_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
11 top_cxx . . $ DStack#top_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
12 number_itemscxx . . $ DStack#number_items. = 0;
13 }
14
15 DStackcxx . . $ DStack#::~cxx . . $ DStack#`~DStack`(ced63f7c635d850d).DStackcxx . . $ DStack#() // how to reclaim memory from local
16 { // stacks when exiting functions
17 clear_stackcxx . . $ DStack#clear_stack(49f6e7a06ebc5aa8).();
18 }
19
20
21 // erase any/all items on the stack
22 void DStackcxx . . $ DStack#::clear_stackcxx . . $ DStack#clear_stack(49f6e7a06ebc5aa8).()
23 {
24 STACKVALUEcxx . . $ STACKVALUE# *current, *next_value;
25 current = bottom_cxx . . $ DStack#bottom_.;
26 while (current)
27 {
28 next_value = (STACKVALUEcxx . . $ STACKVALUE# *) current->nextcxx . . $ $anonymous_type_a6209027130cf9f4_0#next.;
29 freecxx . . $ free(bd21765a0afc8e3c).(current);
30 current = next_value;
31 }
32
33 bottom_cxx . . $ DStack#bottom_. = top_cxx . . $ DStack#top_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
34 number_itemscxx . . $ DStack#number_items. = 0;
35 }
36
37
38 int DStackcxx . . $ DStack#::num_itemscxx . . $ DStack#num_items(b126dc7c1de90089).() // number of items currently in stack
39 {
40 return number_itemscxx . . $ DStack#number_items.;
41 }
42
43 int DStackcxx . . $ DStack#::pushcxx . . $ DStack#push(1bb0578f3efdc255).(float val) // push a new value
44 {
45 STACKVALUEcxx . . $ STACKVALUE# *new_value;
46
47 new_value = (STACKVALUEcxx . . $ STACKVALUE# *) calloccxx . . $ calloc(95acc9b79bb49189).(1, sizeof(STACKVALUEcxx . . $ STACKVALUE#));
48 if (! new_value)
49 return FALSEcxx . . $ `src/dstack.h:6:9`!;
50 new_value->valuecxx . . $ $anonymous_type_a6209027130cf9f4_0#value. = val;
51 if (top_cxx . . $ DStack#top_.)
52 {
53 top_cxx . . $ DStack#top_.->nextcxx . . $ $anonymous_type_a6209027130cf9f4_0#next. = new_value;
54 new_value->previouscxx . . $ $anonymous_type_a6209027130cf9f4_0#previous. = top_cxx . . $ DStack#top_.;
55 top_cxx . . $ DStack#top_. = new_value;
56 }
57 else // no values exist
58 {
59 bottom_cxx . . $ DStack#bottom_. = top_cxx . . $ DStack#top_. = new_value;
60 }
61 number_itemscxx . . $ DStack#number_items.++;
62 return TRUEcxx . . $ `src/dstack.h:9:9`!;
63 }
64
65 float DStackcxx . . $ DStack#::popcxx . . $ DStack#pop(9b8c9e39889c762c).() // pop value from top
66 {
67 float my_return = 0.0;
68 STACKVALUEcxx . . $ STACKVALUE# *new_top = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
69
70 if (top_cxx . . $ DStack#top_.)
71 {
72 my_return = top_cxx . . $ DStack#top_.->valuecxx . . $ $anonymous_type_a6209027130cf9f4_0#value.;
73 new_top = (STACKVALUEcxx . . $ STACKVALUE# *) top_cxx . . $ DStack#top_.->previouscxx . . $ $anonymous_type_a6209027130cf9f4_0#previous.;
74 freecxx . . $ free(bd21765a0afc8e3c).(top_cxx . . $ DStack#top_.);
75 top_cxx . . $ DStack#top_. = new_top;
76 number_itemscxx . . $ DStack#number_items.--;
77 if (! top_cxx . . $ DStack#top_.)
78 bottom_cxx . . $ DStack#bottom_. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
79 }
80 return my_return;
81 }
82
83
84
85 int DStackcxx . . $ DStack#::emptycxx . . $ DStack#empty(b126dc7c1de90089).() // 1 if empty, 0 otherwise
86 {
87 if (number_itemscxx . . $ DStack#number_items.)
88 return FALSEcxx . . $ `src/dstack.h:6:9`!;
89 else
90 return TRUEcxx . . $ `src/dstack.h:9:9`!;
91 }
92
93
94
95 void DStackcxx . . $ DStack#::printcxx . . $ DStack#print(49f6e7a06ebc5aa8).()
96 {
97 STACKVALUEcxx . . $ STACKVALUE# *current;
98 printf("Stack holds %d items.\n", number_itemscxx . . $ DStack#number_items.);
99 current = bottom_cxx . . $ DStack#bottom_.;
100 while (current)
101 {
102 printf("Value: %f\n", current->valuecxx . . $ $anonymous_type_a6209027130cf9f4_0#value.);
103 current = (STACKVALUEcxx . . $ STACKVALUE# *) current->nextcxx . . $ $anonymous_type_a6209027130cf9f4_0#next.;
104 }
105 }
106