From 6309d7ad56357e3aecbfeb7096b434a03bdc70a8 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Mon, 15 Jun 2009 06:45:44 +0000 Subject: continued with localization --- src/base/tl/sorted_array.hpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/base/tl/sorted_array.hpp (limited to 'src/base/tl/sorted_array.hpp') 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 sorted_array : public array +{ + typedef array 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 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 -- cgit 1.4.1