1 | // ---------------------------------------------------------------------------- |
---|
2 | // multicnt.h |
---|
3 | // begin of file |
---|
4 | // Stephan Endrass, endrass@mathematik.uni-mainz.de |
---|
5 | // 23.7.99 |
---|
6 | // ---------------------------------------------------------------------------- |
---|
7 | |
---|
8 | // ---------------------------------------------------------------------------- |
---|
9 | // Description: the class multiCnt is a general multi purpose counter. |
---|
10 | // The counter holds an array cnt of N integers. |
---|
11 | // The integer last_inc holds the index of the last incremented entry. |
---|
12 | // ---------------------------------------------------------------------------- |
---|
13 | |
---|
14 | #ifndef MULTICNT_H |
---|
15 | #define MULTICNT_H |
---|
16 | |
---|
17 | class multiCnt |
---|
18 | { |
---|
19 | public: |
---|
20 | |
---|
21 | int *cnt; |
---|
22 | int N; |
---|
23 | int last_inc; |
---|
24 | |
---|
25 | multiCnt( ); |
---|
26 | multiCnt( int ); |
---|
27 | multiCnt( int,int ); |
---|
28 | multiCnt( int,int* ); |
---|
29 | multiCnt( const multiCnt& ); |
---|
30 | |
---|
31 | void copy_zero ( void ); |
---|
32 | void copy_new ( int ); |
---|
33 | void copy_delete ( void ); |
---|
34 | void copy_shallow( multiCnt& ); |
---|
35 | void copy_deep ( const multiCnt& ); |
---|
36 | |
---|
37 | void set( int ); |
---|
38 | |
---|
39 | void inc ( void ); |
---|
40 | void inc_carry( void ); |
---|
41 | int inc ( int ); |
---|
42 | //void dec ( void ); |
---|
43 | //void dec_carry( void ); |
---|
44 | //int dec ( int ); |
---|
45 | }; |
---|
46 | |
---|
47 | // ---------------------------------------------------------------------------- |
---|
48 | // zero init |
---|
49 | // ---------------------------------------------------------------------------- |
---|
50 | |
---|
51 | inline void multiCnt::copy_zero( void ) |
---|
52 | { |
---|
53 | cnt = (int*)NULL; |
---|
54 | N = 0; |
---|
55 | last_inc = 0; |
---|
56 | } |
---|
57 | |
---|
58 | // ---------------------------------------------------------------------------- |
---|
59 | // copy a counter by reference |
---|
60 | // ---------------------------------------------------------------------------- |
---|
61 | |
---|
62 | inline void multiCnt::copy_shallow( multiCnt &C ) |
---|
63 | { |
---|
64 | cnt = C.cnt; |
---|
65 | N = C.N; |
---|
66 | last_inc = C.last_inc; |
---|
67 | } |
---|
68 | |
---|
69 | // ---------------------------------------------------------------------------- |
---|
70 | // zero constructor |
---|
71 | // ---------------------------------------------------------------------------- |
---|
72 | |
---|
73 | inline multiCnt::multiCnt( ) |
---|
74 | { |
---|
75 | copy_zero( ); |
---|
76 | } |
---|
77 | |
---|
78 | #endif /* MULTICNT_H */ |
---|
79 | |
---|
80 | // ---------------------------------------------------------------------------- |
---|
81 | // multicnt.h |
---|
82 | // end of file |
---|
83 | // ---------------------------------------------------------------------------- |
---|