UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FloatAr.H
1 // FloatAr.H $Revision: 1.10 $ $Date: 2002/10/16 17:37:47 $
2 
3 #if !defined __FloatAr_H
4 
5 #define __FloatAr_H
6 
7 #include <mix/DynAr.H>
8 #include <mix/SortedAr.H>
9 
10 
11 /*************************************************************
12  * Dynamyc Array of Floats
13  *************************************************************/
14 
15 class FloatAr : public SortedAr
16 {
17 public:
18 
19  FloatAr (const FloatAr& flar);
20  FloatAr (unsigned quant = DEFAULT_QUANT,
21  unsigned volume = START_VOLUME);
22 
23  float& fetch (unsigned i);
24  float get (unsigned i) const;
25 
26  void insert (unsigned i, float val);
27 
28  void addh (float val);
29  void addl (float val);
30 
31  void addh (const FloatAr& flar);
32  void addl (const FloatAr& flar);
33 
34  FloatAr& assign (const FloatAr& flar);
35  FloatAr& assign (unsigned cnt, float* vect);
36 
37  float* vector () const;
38 
39  // Synonyms
40  float& operator[] (unsigned i) {return fetch(i);};
41  float operator() (unsigned i) const {return get(i);};
42  FloatAr& operator= (const FloatAr& flar) {return assign(flar);};
43 
44  // Usual compare between two floats
45  virtual Compar compare (const char* item1, const char* item2) const;
46 
47  // Usual exchange between two floats: quicker than DynAr::exchange()
48  virtual void exchange (unsigned i1, unsigned i2);
49 
50  // Return index of item or -1
51  int find_ascent (float item) const
52  {return quick_find_ascent((const char*)&item);}
53  int find_descent (float item) const
54  {return quick_find_descent((const char*)&item);}
55  int find (float 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 (float value,
61  unsigned& L, unsigned& R) const {
62  return SortedAr::find_range_ascent((const char*)&value, L, R);
63  }
64  Compar find_range_descent (float value,
65  unsigned& L, unsigned& R) const {
66  return SortedAr::find_range_descent((const char*)&value, L, R);
67  }
68 
69 
70  // For debug purpose
71  virtual void print_item (unsigned i) const;
72  virtual void print_contents () const;
73 
74 };
75 
76 
77 #endif // FloatAr.H
Definition: SortedAr.H:14
Definition: FloatAr.H:15