acme
Foundational cross-platform layer of the ca2 framework
Toggle main menu visibility
Loading...
Searching...
No Matches
sort_array.h
1
#pragma once
2
3
4
5
//
6
//
7
//template < typename ARG_TYPE >
8
//class default_less :
9
// public less_predicate_base < ARG_TYPE >
10
//{
11
//public:
12
//
13
// virtual bool less(ARG_TYPE a1, ARG_TYPE a2);
14
//
15
//};
16
//
17
//template < typename ARG_TYPE >
18
//class sort_data :
19
// virtual public ::matter
20
//{
21
//public:
22
//
23
//
24
// bool m_bSorted;
25
// ::pointer<index_array> m_pindexa;
26
// pointer< less_predicate_base < ARG_TYPE > > m_pless;
27
//
28
// sort_data()
29
// {
30
//
31
// m_bSorted = false;
32
//
33
// }
34
//
35
// template < typename ARRAY >
36
// void sort(ARRAY * parray);
37
//
38
// void mark_dirty() { m_bSorted = false; }
39
//
40
//};
41
//
42
//template < typename ARG_TYPE >
43
//class sort_map :
44
// virtual public atom_map_base < pointer< sort_data < ARG_TYPE > > >
45
//{
46
//public:
47
//
48
//
49
// inline void mark_dirty();
50
//
51
//
52
//};
53
//
54
//
55
//template < class TYPE, class ARG_TYPE = const TYPE &, class BASE_ARRAY_TYPE = array < TYPE,ARG_TYPE > >
56
//class sort_array :
57
// virtual public matter
58
//{
59
//public:
60
//
61
// typedef TYPE BASE_TYPE;
62
// typedef ARG_TYPE BASE_ARG_TYPE;
63
// typedef BASE_ARRAY_TYPE BASE_ARRAY;
64
// using sort_data = ::sort_data < ARG_TYPE >;
65
// using sort_map = ::sort_map < ARG_TYPE >;
66
//
67
//
68
// sort_map m_map;
69
// ::pointer<BASE_ARRAY_TYPE> m_parray;
70
// ::pointer<sort_data> m_psortdata; // from last get_sort call
71
//
72
//
73
// sort_array() { m_parray = allocateø BASE_ARRAY_TYPE(); }
74
//
75
//
76
// sort_array(BASE_ARRAY_TYPE * parray) : m_parray(parray) { }
77
//
78
// sort_array(const sort_array & a) :
79
// m_map(a.m_map),
80
// m_parray(a.m_parray)
81
// {
82
//
83
// }
84
//
85
//
86
// template < typename PRED >
87
// void add_sort(const ::atom & atom, PRED predLess)
88
// {
89
//
90
// auto& psortmap = m_map[atom];
91
//
92
// defer_construct_newø(psortmap);
93
//
94
// psortmap->m_pless = allocateø less_predicate < ARG_TYPE, PRED > (predLess);
95
//
96
// }
97
//
98
//
99
// index add(ARG_TYPE t)
100
// {
101
//
102
// auto iIndex = m_parray->add(t);
103
//
104
// m_map.mark_dirty();
105
//
106
// return iIndex;
107
//
108
// }
109
//
110
//
111
// template < typename ARRAY >
112
// ::collection::count add_array(const ARRAY & a)
113
// {
114
//
115
// auto c = m_parray->add(a);
116
//
117
// m_map.mark_dirty();
118
//
119
// return c;
120
//
121
// }
122
//
123
//
124
// sort_data * get_sort(const ::atom & atom) const
125
// {
126
//
127
// auto iterator = m_map.find(atom);
128
//
129
// if (!iterator) return nullptr;
130
//
131
// ((sort_array*)this)->m_psortdata = iterator->m_element2;
132
//
133
// return m_psortdata;
134
//
135
// }
136
//
137
//
138
// sort_data * get_sorted(const ::atom & atom) const
139
// {
140
//
141
// auto pdata = get_sort(atom);
142
//
143
// // sort information is considered a const sorting property, i.e.,
144
// // a mutable cache;
145
// pdata->sort(((sort_array *) this)->m_parray.m_p);
146
//
147
// return pdata;
148
//
149
// }
150
//
151
//
152
// bool find(ARG_TYPE t, ::collection::index & iIndex, const ::atom & atom) const;
153
//
154
// bool contains(ARG_TYPE t, const ::atom & atom) const;
155
//
156
// bool add_unique(ARG_TYPE t, const ::atom & atom);
157
//
158
// void sort(const ::atom & atom);
159
//
160
// void set_size(::collection::count ca);
161
//
162
// ::collection::count get_count() const { return m_parray->get_count(); }
163
//
164
// ::collection::index get_upper_bound() const { return m_parray->get_upper_bound(); }
165
//
166
// ::collection::index get_size() const { return m_parray->get_size(); }
167
//
168
// const TYPE & element_at (::collection::index i, const ::atom & atom) const;
169
//
170
// TYPE & element_at (::collection::index i, const ::atom & atom);
171
//
172
// const TYPE & operator [] (::collection::index i) const;
173
//
174
// TYPE & operator [] (::collection::index i);
175
//
176
// //bool operator == (const sort_array & a) const;
177
//
178
// //bool operator != (const sort_array & a) const;
179
//
180
// void copy(const BASE_ARRAY & src);
181
//
182
//
183
// sort_array & operator = (const sort_array & a)
184
// {
185
//
186
// return copy(a);
187
//
188
// }
189
//
190
//
191
// sort_array & copy (const sort_array & a)
192
// {
193
//
194
// if (&a != this)
195
// {
196
//
197
// m_parray = a.m_parray;
198
//
199
// ::acme::map_base::copy(m_map, a.m_map);
200
//
201
// }
202
//
203
// return *this;
204
//
205
// }
206
//
207
// virtual void on_after_read();
208
//
209
//};
210
//
211
//
212
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
213
//bool sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
214
//find(ARG_TYPE t, ::collection::index & iIndex, const ::atom & atom) const
215
//{
216
//
217
// if(m_parray->is_empty())
218
// {
219
//
220
// return false;
221
//
222
// }
223
//
224
// auto psort = get_sorted(atom);
225
//
226
// return ::acme::array::binary_search(
227
// *m_parray,
228
// t,
229
// iIndex,
230
// psort->m_pless,
231
// *psort->m_pindexa);
232
//
233
//}
234
//
235
//
236
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
237
//bool sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
238
//contains(ARG_TYPE t, const ::atom & atom) const
239
//{
240
//
241
// index iIndex = 0;
242
//
243
// return find(t, iIndex, atom);
244
//
245
//}
246
//
247
//
248
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
249
//bool sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
250
//add_unique(ARG_TYPE t, const ::atom & atom)
251
//{
252
//
253
// if (contains(t, atom))
254
// {
255
//
256
// return false;
257
//
258
// }
259
//
260
// add(t);
261
//
262
// return true;
263
//
264
//}
265
//
266
//
267
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
268
//void sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
269
//sort(const ::atom & atom)
270
//{
271
//
272
// ((const sort_array *)this)->get_sorted(atom);
273
//
274
//}
275
//
276
//
277
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
278
//void sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
279
//set_size(::collection::count n)
280
//{
281
//
282
// m_parray->set_size(n);
283
//
284
// m_map.mark_dirty();
285
//
286
//}
287
//
288
//
289
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
290
//TYPE & sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
291
//element_at(::collection::index i, const ::atom & atom)
292
//{
293
//
294
// return m_parray->element_at(get_sort(atom)->m_pindexa->element_at(i));
295
//
296
//}
297
//
298
//
299
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
300
//const TYPE & sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
301
//element_at(::collection::index i, const ::atom & atom) const
302
//{
303
//
304
// return ((sort_array *) this)->element_at(i, atom);
305
//
306
//}
307
//
308
//
309
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
310
//TYPE & sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
311
//operator [](::collection::index i)
312
//{
313
//
314
// i = ::is_set(m_psortdata) && m_psortdata->m_bSorted ? m_psortdata->m_pindexa->element_at(i) : i;
315
//
316
// return m_parray->element_at(i);
317
//
318
//}
319
//
320
//
321
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
322
//const TYPE & sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::
323
//operator [](::collection::index i) const
324
//{
325
//
326
// return ((sort_array *) this)->operator [](i);
327
//
328
//}
329
//
354
//
363
//
364
//template < class TYPE, class ARG_TYPE, class BASE_ARRAY >
365
//void sort_array < TYPE, ARG_TYPE, BASE_ARRAY >::on_after_read()
366
//{
367
//
368
// m_map.mark_dirty();
369
//
370
//}
371
//
372
//
374
//#define spsa(T) sort_array < pointer < T >, const pointer < T > &, pointer_array < T > >
375
//
376
//
377
//using sort_int_ptr_array = sort_array < ::collection::index > ;
378
//template < typename TYPE >
379
//using sort_pointer_array = sort_array < ::pointer<TYPE> const ::pointer<TYPE>, pointer_array < TYPE > >;
prototype
collection
sort_array.h
Generated by
1.17.0