Compact_container clean ups.

This commit is contained in:
Sylvain Pion 2003-05-16 13:08:27 +00:00
parent 305151e843
commit b51a08b423
2 changed files with 6 additions and 46 deletions

View File

@ -2,6 +2,9 @@
// Revision History for package STL_Extension // Revision History for package STL_Extension
//===================================================================== //=====================================================================
Version 2.77 (16 May 2003)
Compact_container clean ups.
Version 2.76 (15 May 2003) Version 2.76 (15 May 2003)
Nested_iterator and Concatenate_iterator fixes for MipsPro. Nested_iterator and Concatenate_iterator fixes for MipsPro.

View File

@ -48,15 +48,7 @@
// a free/used/boundary element. // a free/used/boundary element.
// TODO : // TODO :
// - CC_iterator<>'s default ctor initializing to NULL ?
// - For the block_size : increment it linearly, so that for N elements,
// we get O(sqrt(N)) blocks of O(sqrt(N)) elements each ?
// This way we will obtain the asymptotic memory complexity we claim.
// However, in order to allocate large blocks, we need to be able to
// specify the block size with a member function.
// - Add .reserve() and .resize() (and proper copy of capacity_). // - Add .reserve() and .resize() (and proper copy of capacity_).
// - Submit Insert_iterator (and reference it in the doc).
// - Write a test and an example program, documentation in STL_extension.
// - Add preconditions in input that real pointers need to have clean bits. // - Add preconditions in input that real pointers need to have clean bits.
// Also for the allocated memory alignment, and sizeof(). // Also for the allocated memory alignment, and sizeof().
// - Do a benchmark before/after. // - Do a benchmark before/after.
@ -195,16 +187,8 @@ public:
iterator begin() { return iterator(first_item); } iterator begin() { return iterator(first_item); }
iterator end() { return iterator(last_item, 0); } iterator end() { return iterator(last_item, 0); }
#if 0
const_iterator begin() const { return const_iterator(first_item); } const_iterator begin() const { return const_iterator(first_item); }
const_iterator end() const { return const_iterator(last_item, 0); } const_iterator end() const { return const_iterator(last_item, 0); }
#else
// We have to cheat, because Triangulation_[23] is not const-correct.
// The cheating should be moved to the TDS_[23] level, I guess.
// TODO : I can commit the changes to TDS_[23] already now...
iterator begin() const { return const_cast<Self&>(*this).begin(); }
iterator end() const { return const_cast<Self&>(*this).end(); }
#endif
reverse_iterator rbegin() { return reverse_iterator(end()); } reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); } reverse_iterator rend() { return reverse_iterator(begin()); }
@ -222,7 +206,7 @@ public:
pointer ret = free_list; pointer ret = free_list;
free_list = clean_pointee(ret); free_list = clean_pointee(ret);
alloc.construct(ret, t); alloc.construct(ret, t);
Traits::pointer(*ret) = NULL; // FIXME : assertion instead ? CGAL_assertion(Traits::pointer(*ret) == NULL);
++size_; ++size_;
return iterator(ret, 0); return iterator(ret, 0);
} }
@ -261,29 +245,6 @@ public:
// The complexity is O(size(free list = capacity-size)). // The complexity is O(size(free list = capacity-size)).
void merge(Self &d); void merge(Self &d);
// Historical Cruft for TDS :
// But compared to insert(), we used to avoid a copy
// => benchmark before using it (however, TDS can now use non default ctors)
// pointer get_new_element()
// {
// return &*insert(T());
// }
// Historical cruft for TDS.
void release_element(pointer x)
{
erase(iterator(x, 0));
}
// Historical cruft for TDS. It should go in TDS.
bool is_element(const_pointer x) const
{
for (const_iterator it = begin(); it != end(); ++it)
if (&*it == x)
return true;
return false;
}
size_type size() const size_type size() const
{ {
CGAL_expensive_assertion(size_ == CGAL_expensive_assertion(size_ ==
@ -545,7 +506,7 @@ namespace CGALi {
typedef typename DSC::difference_type difference_type; typedef typename DSC::difference_type difference_type;
typedef std::bidirectional_iterator_tag iterator_category; typedef std::bidirectional_iterator_tag iterator_category;
CC_iterator() {} CC_iterator() : p() {}
// Either a harmless copy-ctor, // Either a harmless copy-ctor,
// or a conversion from iterator to const_iterator. // or a conversion from iterator to const_iterator.
@ -559,11 +520,8 @@ namespace CGALi {
// Only Compact_container should access these constructors. // Only Compact_container should access these constructors.
friend class Compact_container<value_type, typename DSC::allocator_type>; friend class Compact_container<value_type, typename DSC::allocator_type>;
public:
// the following should be private and explicit, but TDS needs it now...
// For begin() // For begin()
CC_iterator(pointer ptr) explicit CC_iterator(pointer ptr)
: p(ptr) : p(ptr)
{ {
if (p == NULL) // empty container. if (p == NULL) // empty container.
@ -682,7 +640,6 @@ namespace CGALi {
return &*rhs != &*lhs; return &*rhs != &*lhs;
} }
// The following comparison operator is here so that the iterators // The following comparison operator is here so that the iterators
// can be put directly in set/map (i.e. std::less<> just works). // can be put directly in set/map (i.e. std::less<> just works).
// But maybe it's confusing ? // But maybe it's confusing ?