… | |
… | |
17 | static bool network () { return e == 0x11223344; }; |
17 | static bool network () { return e == 0x11223344; }; |
18 | static bool little_endian () { return e == 0x44332211; }; |
18 | static bool little_endian () { return e == 0x44332211; }; |
19 | static bool vax () { return e == 0x44332211; }; |
19 | static bool vax () { return e == 0x44332211; }; |
20 | } byteorder; |
20 | } byteorder; |
21 | |
21 | |
|
|
22 | // various utility functions |
22 | template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } |
23 | template<typename T, typename U> static inline T min (T a, U b) { return a < (T)b ? a : (T)b; } |
23 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
24 | template<typename T, typename U> static inline void min_it (T &a, U b) { a = a < (T)b ? a : (T)b; } |
24 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
25 | template<typename T, typename U> static inline T max (T a, U b) { return a > (T)b ? a : (T)b; } |
25 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
26 | template<typename T, typename U> static inline void max_it (T &a, U b) { a = a > (T)b ? a : (T)b; } |
26 | |
27 | |
… | |
… | |
35 | |
36 | |
36 | // in range excluding end |
37 | // in range excluding end |
37 | #define IN_RANGE_EXC(val,beg,end) \ |
38 | #define IN_RANGE_EXC(val,beg,end) \ |
38 | ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) |
39 | ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) |
39 | |
40 | |
|
|
41 | // makes dynamically allocated objects zero-initialised |
40 | struct zero_initialized { |
42 | struct zero_initialized { |
41 | void *operator new (size_t s); |
43 | void *operator new (size_t s); |
42 | void operator delete (void *p, size_t s); |
44 | void operator delete (void *p, size_t s); |
43 | }; |
45 | }; |
44 | |
46 | |
… | |
… | |
254 | return pos; |
256 | return pos; |
255 | } |
257 | } |
256 | void erase (iterator first, iterator last) |
258 | void erase (iterator first, iterator last) |
257 | { |
259 | { |
258 | if (last != first) { |
260 | if (last != first) { |
259 | memmove (first, last, (end ()-last)*sizeof (T)); |
261 | memmove (first, last, (end () - last) * sizeof (T)); |
260 | _last -= last - first; |
262 | _last -= last - first; |
261 | } |
263 | } |
262 | } |
264 | } |
263 | void erase (iterator pos) |
265 | void erase (iterator pos) |
264 | { |
266 | { |
265 | if (pos != end ()) { |
267 | if (pos != end ()) { |
266 | memmove (pos, pos+1, (end ()- (pos+1))*sizeof (T)); |
268 | memmove (pos, pos+1, (end () - (pos+1)) * sizeof (T)); |
267 | --_last; |
269 | --_last; |
268 | } |
270 | } |
269 | } |
271 | } |
270 | void swap (simplevec<T> &t) |
272 | void swap (simplevec<T> &t) |
271 | { |
273 | { |