6 #include <mix/SortedAr.H>
84 #define AnyCmp(x,y) (EQUAL)
88 #error "AnyType must be defined as type of array's item"
92 #error "AnyAr must be defined as name of generated class of array"
96 #define AnyArQuant DEFAULT_QUANT
100 #define AnyArVolume START_VOLUME
104 #define AnyPrintf fprintf(stderr,
113 AnyAr (
unsigned quant = AnyArQuant,
114 unsigned volume = AnyArVolume)
115 :
SortedAr(
sizeof(AnyType), quant, volume) {};
117 AnyType& fetch (
unsigned i)
118 {
return *(AnyType*)item_ptr(i);};
119 AnyType
get (
unsigned i)
const
120 {
return *(AnyType*)item_ptr(i);};
122 void insert (
unsigned i,
const AnyType& val)
123 {SortedAr::insert(i, (
const char*)&val);};
125 void addh (
const AnyType& val) {SortedAr::addh((
const char*)&val);};
126 void addl (
const AnyType& val) {SortedAr::addl((
const char*)&val);};
128 void addh (
const AnyAr& pArray) {SortedAr::addh(pArray);};
129 void addl (
const AnyAr& pArray) {SortedAr::addl(pArray);};
132 {SortedAr::assign(pArray);
return *
this;};
135 AnyType& operator[] (
unsigned i)
137 AnyType operator() (
unsigned i)
const
140 {
return assign(pArray);};
143 virtual Compar compare (
const char* item1,
const char* item2)
const
144 {
return AnyCmp((*(AnyType*)item1), (*(AnyType*)item2));};
147 int find_ascent (AnyType& item)
const
148 {
return quick_find_ascent((
const char*)&item);}
149 int find_descent (AnyType& item)
const
150 {
return quick_find_descent((
const char*)&item);}
151 int find (AnyType& item)
const
152 {
return slow_find((
const char*)&item);}
156 Compar find_range_ascent (AnyType& value,
157 unsigned& L,
unsigned& R)
const {
158 return SortedAr::find_range_ascent((
const char*)&value, L, R);
160 Compar find_range_descent (AnyType& value,
161 unsigned& L,
unsigned& R)
const {
162 return SortedAr::find_range_descent((
const char*)&value, L, R);
167 virtual void print_item (
unsigned i)
const
168 {AnyType&item=*(AnyType*)item_ptr(i);AnyPrintItem;}
170 #elif defined(AnyFormatSpec) && defined(AnyPrintList)
171 virtual void print_item (
unsigned i)
const
172 {AnyType&item=*(AnyType*)item_ptr(i);
173 AnyPrintf AnyFormatSpec, AnyPrintList);}
Definition: SortedAr.H:14