UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IntAr.H
1 // IntAr.H $Revision: 1.8 $ $Date: 2002/10/16 17:37:47 $
2 
3 #if !defined __IntAr_H
4 
5 #define __IntAr_H
6 
7 #include <mix/SortedAr.H>
8 
9 
10 /*************************************************************
11  * Dynamyc Array of Ints
12  *************************************************************/
13 
14 class IntAr : public SortedAr
15 {
16 public:
17 
18  IntAr (const IntAr& intar);
19  IntAr (unsigned quant = DEFAULT_QUANT,
20  unsigned volume = START_VOLUME);
21 
22  int& fetch (unsigned i);
23  int get (unsigned i) const;
24 
25  void insert (unsigned i, int val);
26 
27  void addh (int val);
28  void addl (int val);
29 
30  void addh (const IntAr& intar);
31  void addl (const IntAr& intar);
32 
33  IntAr& assign (const IntAr& intar);
34  IntAr& assign (unsigned cnt, int* vect);
35 
36  // Allocate vector by calloc() of ints and return pointer
37  int* vector () const;
38 
39  // Synonyms
40  int& operator[] (unsigned i) {return fetch(i);};
41  int operator() (unsigned i) const {return get(i);};
42  IntAr& operator= (const IntAr& intar) {return assign(intar);};
43 
44  // Usual compare between two ints
45  virtual Compar compare (const char* item1, const char* item2) const;
46 
47  // Usual exchange between two ints: quicker than DynAr::exchange()
48  virtual void exchange (unsigned i1, unsigned i2);
49 
50  // Return index of item or -1
51  int find_ascent (int item) const
52  {return quick_find_ascent((const char*)&item);}
53  int find_descent (int item) const
54  {return quick_find_descent((const char*)&item);}
55  int find (int item) const
56  {return slow_find((const char*)&item);}
57 
58  // Return LESS or GREATER in case of out of range and EQUAL means
59  // the L..R is found (L<=R)
60  Compar find_range_ascent (int value,
61  unsigned& L, unsigned& R) const {
62  return SortedAr::find_range_ascent((const char*)&value, L, R);
63  }
64  Compar find_range_descent (int value,
65  unsigned& L, unsigned& R) const {
66  return SortedAr::find_range_descent((const char*)&value, L, R);
67  }
68 
69  // For debug purpose
70  virtual void print_item (unsigned i) const;
71  virtual void print_contents () const;
72 
73 };
74 
75 
76 /*************************************************************
77  * Dynamic Array of Unsigned Ints
78  *************************************************************/
79 
80 class UIntAr : public SortedAr
81 {
82 public:
83 
84  UIntAr (const UIntAr& uintar);
85  UIntAr (unsigned quant = DEFAULT_QUANT,
86  unsigned volume = START_VOLUME);
87 
88  unsigned& fetch (unsigned i);
89  unsigned get (unsigned i) const;
90 
91  void insert (unsigned i, unsigned val);
92 
93  void addh (unsigned val);
94  void addl (unsigned val);
95 
96  void addh (const UIntAr& uintar);
97  void addl (const UIntAr& uintar);
98 
99  UIntAr& assign (const UIntAr& uintar);
100  UIntAr& assign (unsigned cnt, unsigned* vect);
101 
102  // Allocate vector by calloc() of ints and return pointer
103  unsigned* vector () const;
104 
105  // Synonyms
106  unsigned& operator[] (unsigned i) {return fetch(i);};
107  unsigned operator() (unsigned i) const {return get(i);};
108  UIntAr& operator= (const UIntAr& uintar) {return assign(uintar);};
109 
110  // Usual compare between two unsigneds
111  virtual Compar compare (const char* item1, const char* item2) const;
112 
113  // Usual exchange between two unsigneds: quicker than DynAr::exchange()
114  virtual void exchange (unsigned i1, unsigned i2);
115 
116  // Return index of item or -1
117  int find_ascent (unsigned item) const
118  {return quick_find_ascent((const char*)&item);}
119  int find_descent (unsigned item) const
120  {return quick_find_descent((const char*)&item);}
121  int find (unsigned item) const
122  {return slow_find((const char*)&item);}
123 
124  // Return LESS or GREATER in case of out of range and EQUAL means
125  // the L..R is found (L<=R)
126  Compar find_range_ascent (unsigned value,
127  unsigned& L, unsigned& R) const {
128  return SortedAr::find_range_ascent((const char*)&value, L, R);
129  }
130  Compar find_range_descent (unsigned value,
131  unsigned& L, unsigned& R) const {
132  return SortedAr::find_range_descent((const char*)&value, L, R);
133  }
134 
135  // For debug purpose
136  virtual void print_item (unsigned i) const;
137  virtual void print_contents () const;
138 
139 };
140 
141 
142 #endif // IntAr.H
Definition: SortedAr.H:14
Definition: IntAr.H:80
Definition: IntAr.H:14