diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-15 06:45:44 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2009-06-15 06:45:44 +0000 |
| commit | 6309d7ad56357e3aecbfeb7096b434a03bdc70a8 (patch) | |
| tree | 1bf4e300ee2cd13e855c68a6e2160cbc98a06abb /src/base/tl/sorted_array.hpp | |
| parent | bc20e9c433c1c7bd2a9516a936d1d7ffee1e90f2 (diff) | |
| download | zcatch-6309d7ad56357e3aecbfeb7096b434a03bdc70a8.tar.gz zcatch-6309d7ad56357e3aecbfeb7096b434a03bdc70a8.zip | |
continued with localization
Diffstat (limited to 'src/base/tl/sorted_array.hpp')
| -rw-r--r-- | src/base/tl/sorted_array.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/base/tl/sorted_array.hpp b/src/base/tl/sorted_array.hpp new file mode 100644 index 00000000..bb09aba9 --- /dev/null +++ b/src/base/tl/sorted_array.hpp @@ -0,0 +1,31 @@ +#ifndef TL_FILE_SORTED_ARRAY_HPP +#define TL_FILE_SORTED_ARRAY_HPP + +#include "algorithms.hpp" +#include "array.hpp" + +template <class T, class ALLOCATOR = allocator_default<T> > +class sorted_array : public array<T, ALLOCATOR> +{ + typedef array<T, ALLOCATOR> parent; + + // insert and size is not allowed + int insert(const T& item, typename parent::range r) { dbg_break(); return 0; } + int set_size(int new_size) { dbg_break(); return 0; } + +public: + typedef plain_range_sorted<T> range; + + int add(const T& item) + { + return parent::insert(item, partition_binary(all(), item)); + } + + /* + Function: all + Returns a sorted range that contains the whole array. + */ + range all() { return range(parent::list, parent::list+parent::num_elements); } +}; + +#endif // TL_FILE_SORTED_ARRAY_HPP |