My Project
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
multiCnt Class Reference

#include <multicnt.h>

Public Member Functions

 multiCnt ()
 
 multiCnt (int)
 
 multiCnt (int, int)
 
 multiCnt (int, int *)
 
 multiCnt (const multiCnt &)
 
void copy_zero (void)
 
void copy_new (int)
 
void copy_delete (void)
 
void copy_shallow (multiCnt &)
 
void copy_deep (const multiCnt &)
 
void set (int)
 
void inc (void)
 
void inc_carry (void)
 
int inc (int)
 

Data Fields

int * cnt
 
int N
 
int last_inc
 

Detailed Description

Definition at line 17 of file multicnt.h.

Constructor & Destructor Documentation

◆ multiCnt() [1/5]

multiCnt::multiCnt ( )
inline

Definition at line 73 of file multicnt.h.

74{
75 copy_zero( );
76}
void copy_zero(void)
Definition: multicnt.h:51

◆ multiCnt() [2/5]

multiCnt::multiCnt ( int  n)

Definition at line 118 of file multicnt.cc.

118 :
119 last_inc( 0 )
120{
121 copy_new( n );
122 N = n;
123 set( 0 );
124}
void copy_new(int)
Definition: multicnt.cc:32
void set(int)
Definition: multicnt.cc:108
int last_inc
Definition: multicnt.h:23
int N
Definition: multicnt.h:22

◆ multiCnt() [3/5]

multiCnt::multiCnt ( int  n,
int  c 
)

Definition at line 130 of file multicnt.cc.

130 :
131 last_inc( 0 )
132{
133 copy_new( n );
134 N = n;
135 set( c );
136}

◆ multiCnt() [4/5]

multiCnt::multiCnt ( int  n,
int *  c 
)

Definition at line 142 of file multicnt.cc.

142 :
143 last_inc( 0 )
144{
145 copy_new( n );
146 N = n;
147 for( int i=0; i<N; i++ ) cnt[i] = c[i];
148}
int i
Definition: cfEzgcd.cc:132
int * cnt
Definition: multicnt.h:21

◆ multiCnt() [5/5]

multiCnt::multiCnt ( const multiCnt )

Member Function Documentation

◆ copy_deep()

void multiCnt::copy_deep ( const multiCnt C)

Definition at line 91 of file multicnt.cc.

92{
93 copy_new( C.N );
94
96 N = C.N;
97
98 for( int i=0; i<N; i++ )
99 {
100 cnt[i] = C.cnt[i];
101 }
102}

◆ copy_delete()

void multiCnt::copy_delete ( void  )

Definition at line 81 of file multicnt.cc.

82{
83 if( N>0 && cnt!=(int*)NULL ) delete [] cnt;
84 copy_zero( );
85}
#define NULL
Definition: omList.c:12

◆ copy_new()

void multiCnt::copy_new ( int  n)

Definition at line 32 of file multicnt.cc.

33{
34 if( n > 0 )
35 {
36 cnt = new int[n];
37
38 #ifndef SING_NDEBUG
39 if( cnt == (int*)NULL )
40 {
41 #ifdef MULTICNT_PRINT
42 #ifdef MULTICNT_IOSTREAM
43 cerr << "multiCnt::copy_new(" << n << ")" << endl;
44 cerr << " returned ZERO!!!" << endl;
45 cerr << " exit..." << endl;
46 #else
47 fprintf( stderr,"multiCnt::copy_new( %d )\n",n );
48 fprintf( stderr," returned ZERO!!!\n" );
49 fprintf( stderr," exit...\n" );
50 #endif
51 #endif
52
53 exit( 1 );
54 }
55 #endif
56 }
57 else if( n == 0 )
58 {
59 cnt = (int*)NULL;
60 }
61 else
62 {
63 #ifdef MULTICNT_PRINT
64 #ifdef MULTICNT_IOSTREAM
65 cerr << "multiCnt::copy_new(" << n << ")" << endl;
66 cerr << " exit..." << endl;
67 #else
68 fprintf( stderr,"multiCnt::copy_new( %d )\n",n );
69 fprintf( stderr," exit...\n" );
70 #endif
71 #endif
72
73 exit( 1 );
74 }
75}

◆ copy_shallow()

void multiCnt::copy_shallow ( multiCnt C)
inline

Definition at line 62 of file multicnt.h.

63{
64 cnt = C.cnt;
65 N = C.N;
67}

◆ copy_zero()

void multiCnt::copy_zero ( void  )
inline

Definition at line 51 of file multicnt.h.

52{
53 cnt = (int*)NULL;
54 N = 0;
55 last_inc = 0;
56}

◆ inc() [1/2]

int multiCnt::inc ( int  carry)

Definition at line 200 of file multicnt.cc.

201{
202 if( carry==FALSE )
203 {
204 inc( );
205 }
206 else
207 {
208 if( last_inc==N-1 )
209 {
210 return FALSE;
211 }
212
213 inc_carry( );
214 }
215
216 return TRUE;
217}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void inc_carry(void)
Definition: multicnt.cc:176
void inc(void)
Definition: multicnt.cc:154

◆ inc() [2/2]

void multiCnt::inc ( void  )

Definition at line 154 of file multicnt.cc.

155{
156 cnt[0]++;
157 last_inc=0;
158}

◆ inc_carry()

void multiCnt::inc_carry ( void  )

Definition at line 176 of file multicnt.cc.

177{
178 for( int i=0; i<=last_inc; i++ ) cnt[i] = 0;
179 last_inc++;
180 cnt[last_inc]++;
181}

◆ set()

void multiCnt::set ( int  c)

Definition at line 108 of file multicnt.cc.

109{
110 for( int i=0; i<N; i++ ) cnt[i]=c;
111}

Field Documentation

◆ cnt

int* multiCnt::cnt

Definition at line 21 of file multicnt.h.

◆ last_inc

int multiCnt::last_inc

Definition at line 23 of file multicnt.h.

◆ N

int multiCnt::N

Definition at line 22 of file multicnt.h.


The documentation for this class was generated from the following files: