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