UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
BoolAr.H
1 /* BoolAr.H */
2 /* $Id: BoolAr.H,v 2.1 2004/04/19 07:37:14 vlad Exp $ */
3 #ifndef __BoolAr_H
4 #define __BoolAr_H
5 
6 
7 #include <mix/SortedAr.H>
8 
9 
10 /*************************************************************
11  * Dynamyc Array of Ints
12  *************************************************************/
13 
14 class BoolAr : public SortedAr
15 {
16 public:
17 
18  BoolAr (const BoolAr& boolar);
19  BoolAr (unsigned quant = DEFAULT_QUANT,
20  unsigned volume = START_VOLUME);
21 
22  bool& fetch (unsigned i);
23  bool get (unsigned i) const;
24 
25  void insert (unsigned i, bool val);
26 
27  void addh (bool val);
28  void addl (bool val);
29 
30  void addh (const BoolAr& boolar);
31  void addl (const BoolAr& boolar);
32 
33  BoolAr& assign (const BoolAr& boolar);
34  BoolAr& assign (unsigned cnt, bool* vect);
35 
36  // Allocate vector by calloc() of ints and return pointer
37  bool* vector () const;
38 
39  // Synonyms
40  bool& operator[] (unsigned i) {return fetch(i);};
41  bool operator() (unsigned i) const {return get(i);};
42  BoolAr& operator= (const BoolAr& BoolAr) {return assign(BoolAr);};
43 
44  // Usual compare between two boolean values
45  virtual Compar compare (const char* item1, const char* item2) const;
46 
47  // Usual exchange between two boolean values: 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 #endif /* BoolAr.H */
Definition: SortedAr.H:14
Definition: BoolAr.H:14