2 #ifndef _fei_ctg_set_hpp_
3 #define _fei_ctg_set_hpp_
102 if (i_ < set_->
len_-2) {
174 for(
int i=0; i<
len_; ++i) {
198 std::pair<const_iterator,bool>
insert(
const T& item)
209 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, 0),
true));
214 if (insertPoint <
len_) {
251 if (
dataptr_[insertPoint] == item) {
252 if (insertPoint%2 == 0) {
254 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, insertPoint),
false));
264 if (insertPoint <
len_-1) {
268 int nmove=
len_-insertPoint-1;
272 std::memmove(dest, src, nmove*
sizeof(T));
277 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, insertPoint-1),
true));
282 if (insertPoint%2 == 0) {
283 if (item ==
dataptr_[insertPoint]-1) {
285 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, insertPoint),
true));
289 int nmove =
len_-insertPoint;
298 std::memmove(dest, src, nmove*
sizeof(T));
303 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, insertPoint),
true));
307 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, insertPoint-1),
false));
322 return(std::pair<const_iterator,bool>(
const_iterator(
this, item, insertPoint),
true));
339 if (insertPoint <
len_) {
366 if (insertPoint%2==0) {
367 switch(
dataptr_[insertPoint]-item) {
375 int nmove =
len_-insertPoint;
384 std::memmove(dest, src, nmove*
sizeof(T));
392 if (
dataptr_[insertPoint] == item) {
397 if (insertPoint <
len_-1 &&
401 int nmove=
len_-insertPoint-1;
405 std::memmove(dest, src, nmove*
sizeof(T));
429 for(
int i=0; i<group_size; ++i) {
443 int insertPoint = -1;
447 if (insertPoint%2==0) {
469 for(; iter != iter_end; ++iter) {
474 items[offset++] = *iter;
485 T* itemsPtr = &(items[0]);
494 while(offset<(
len_-1)) {
510 T* newptr =
new T[newlen];
int insert2_dense_group(const T &starting_index, int group_size)
int copy_to_vector(std::vector< T > &items) const
ctg_set(int alloc_incr=32)
const_iterator find(const T &item)
const_iterator(const ctg_set< T > *_set, const T &val, int i)
int binarySearch(const T &item, const T *list, int len)
int lowerBound(const T &item, const T *list, int len)
const_iterator begin() const
bool operator!=(const ctg_set< T > &rhs)
void insert2(const T &item)
ctg_set(const ctg_set< T > &src)
const_iterator & operator=(const const_iterator &src)
const_iterator(const const_iterator &src)
int copy_to_array(int len, T *items) const
bool operator!=(const const_iterator &rhs)
const T & operator*() const
static const_iterator end()
std::pair< const_iterator, bool > insert(const T &item)
bool operator==(const const_iterator &rhs)
void expand_dataptr(int newlen)
const_iterator & operator++()
virtual ~const_iterator()
friend class const_iterator
const ctg_set< T > * set_
ctg_set< T > & operator=(const ctg_set< T > &src)