13 #ifndef __GU_OrderedIndexGroup__
14 #define __GU_OrderedIndexGroup__
23 template<
typename INDEX>
27 template<
typename INDEX>
42 if (it == myIndices.end())
45 myIndices.insert(std::make_pair(idx, order));
50 myOrder(it->second) = tombstone<INDEX>();
51 it->second = myOrder.
append(idx);
63 if (it == myIndices.end())
67 myOrder(order) = tombstone<INDEX>();
85 return myIndices.find(idx) != myIndices.end();
88 bool contains(
const INDEX &idx, INDEX &contained_idx)
const
93 if (it != myIndices.end())
95 contained_idx = myOrder(it->second);
103 size_t size()
const {
return myIndices.size(); }
105 bool empty()
const {
return myIndices.empty(); }
125 do { ++myIt; }
while(myIt != myEnd && *myIt == tombstone<INDEX>());
132 : myIt(it), myEnd(end)
135 while(myIt != myEnd && *myIt == tombstone<INDEX>())
145 return const_iterator(myOrder.
begin(), myOrder.
end());
147 const_iterator
end()
const
149 return const_iterator(myOrder.
end(), myOrder.
end());
152 void dump(std::ostream &os)
const
156 os <<
"[ " << oi.first <<
", " << oi.second <<
"] ";
158 os <<
"Order: " << myOrder <<
"\n";
164 myIndices.swap(group.myIndices);
165 myOrder.
swap(group.myOrder);
181 for (
int i = 0, ie = myOrder.
size(); i < ie; i++)
183 if (myOrder(i) == tombstone<INDEX>())
188 myOrder(order) = myOrder(i);
189 order_remap(i) = order++;
202 oi.second = order_remap(oi.second);
210 int64 mem = inclusive ?
sizeof(*this) : 0;
212 mem += myIndices.bucket_count() *
sizeof(
void*);
213 mem += myIndices.size() * (
sizeof(size_t) +
sizeof(
void*) +
sizeof(INDEX));
224 #endif // __GU_OrderedIndexGroup__
bool erase(const INDEX &idx)
const INDEX & operator*()
const_iterator begin() const
void swap(UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &a, UT::ArraySet< Key, MULTI, MAX_LOAD_FACTOR_256, Clearer, Hash, KeyEqual > &b)
bool contains(const INDEX &idx, INDEX &contained_idx) const
void setSizeNoInit(exint newsize)
int64 getMemoryUsage(bool inclusive=false) const
void append(const INDEX &idx)
const_iterator(const typename IndexOrder::const_iterator &it, const typename IndexOrder::const_iterator &end)
int64 getMemoryUsage(bool inclusive) const
void swap(GU_OrderedIndexGroup &group)
GLdouble GLdouble GLint GLint order
const_iterator & operator++()
void dump(std::ostream &os) const
bool operator!=(const const_iterator &it)
std::forward_iterator_tag iterator_category
const_iterator end() const
bool contains(const INDEX &idx) const
bool operator==(const const_iterator &it)
base_iterator< const INDEX, true > const_iterator
void truncate(exint maxsize)
Decreases, but never expands, to the given maxsize.
std::ptrdiff_t difference_type
Base::value_type value_type
void clear()
Resets list to an empty list.
Base::const_iterator const_iterator
void swap(UT_Array< T > &other)
iterator end()
End iterator.