Additional vector speed improvements, added basic benchmark against varray

[SVN r83126]
This commit is contained in:
Ion Gaztañaga committed 2013-02-24 13:13:36 +00:00
1 parent b3d5f6480b
commit 0896d04ddf
19 files changed
+5296 -924

No files matched your search

+42 -26
View File
@@ -57,20 +57,29 @@ class static_storage_allocator
public:
typedef T value_type;
T* internal_storage() const
static_storage_allocator() BOOST_CONTAINER_NOEXCEPT
{}
static_storage_allocator(const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT
{}
static_storage_allocator & operator=(const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT
{}
T* internal_storage() const BOOST_CONTAINER_NOEXCEPT
{ return const_cast<T*>(static_cast<const T*>(static_cast<const void*>(&storage))); }
T* internal_storage()
T* internal_storage() BOOST_CONTAINER_NOEXCEPT
{ return static_cast<T*>(static_cast<void*>(&storage)); }
static const std::size_t internal_capacity = N;
typedef boost::container::container_detail::version_type<static_storage_allocator, 0> version;
friend bool operator==(const static_storage_allocator &, const static_storage_allocator &)
friend bool operator==(const static_storage_allocator &, const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT
{ return false; }
friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &)
friend bool operator!=(const static_storage_allocator &, const static_storage_allocator &) BOOST_CONTAINER_NOEXCEPT
{ return true; }
private:
@@ -123,7 +132,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
static_vector()
static_vector() BOOST_CONTAINER_NOEXCEPT
: base_t()
{}
@@ -386,7 +395,7 @@ public:
//!
//! @par Complexity
//! Linear O(N).
void reserve(size_type count);
void reserve(size_type count) BOOST_CONTAINER_NOEXCEPT;
//! @pre <tt>size() < capacity()</tt>
//!
@@ -594,7 +603,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
void clear();
void clear() BOOST_CONTAINER_NOEXCEPT;
//! @pre <tt>i < size()</tt>
//!
@@ -724,7 +733,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
Value * data();
Value * data() BOOST_CONTAINER_NOEXCEPT;
//! @brief Const pointer such that <tt>[data(), data() + size())</tt> is a valid range.
//! For a non-empty vector <tt>data() == &front()</tt>.
@@ -734,7 +743,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const Value * data() const;
const Value * data() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns iterator to the first element.
//!
@@ -745,7 +754,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
iterator begin();
iterator begin() BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const iterator to the first element.
//!
@@ -756,7 +765,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_iterator begin() const;
const_iterator begin() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const iterator to the first element.
//!
@@ -767,7 +776,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_iterator cbegin() const;
const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns iterator to the one after the last element.
//!
@@ -778,7 +787,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
iterator end();
iterator end() BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const iterator to the one after the last element.
//!
@@ -789,7 +798,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_iterator end() const;
const_iterator end() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const iterator to the one after the last element.
//!
@@ -800,7 +809,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_iterator cend() const;
const_iterator cend() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns reverse iterator to the first element of the reversed container.
//!
@@ -812,7 +821,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
reverse_iterator rbegin();
reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const reverse iterator to the first element of the reversed container.
//!
@@ -824,7 +833,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_reverse_iterator rbegin() const;
const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const reverse iterator to the first element of the reversed container.
//!
@@ -836,7 +845,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_reverse_iterator crbegin() const;
const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns reverse iterator to the one after the last element of the reversed container.
//!
@@ -848,7 +857,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
reverse_iterator rend();
reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const reverse iterator to the one after the last element of the reversed container.
//!
@@ -860,7 +869,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_reverse_iterator rend() const;
const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns const reverse iterator to the one after the last element of the reversed container.
//!
@@ -872,7 +881,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
const_reverse_iterator crend() const;
const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns container's capacity.
//!
@@ -883,7 +892,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
static size_type capacity();
static size_type capacity() BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns container's capacity.
//!
@@ -894,7 +903,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
static size_type max_size();
static size_type max_size() BOOST_CONTAINER_NOEXCEPT;
//! @brief Returns the number of stored elements.
//!
@@ -905,7 +914,7 @@ public:
//!
//! @par Complexity
//! Constant O(1).
size_type size() const;
size_type size() const BOOST_CONTAINER_NOEXCEPT;
//! @brief Queries if the container contains elements.
//!
@@ -917,7 +926,13 @@ public:
//!
//! @par Complexity
//! Constant O(1).
bool empty() const;
bool empty() const BOOST_CONTAINER_NOEXCEPT;
#else
friend void swap(static_vector &x, static_vector &y)
{
x.swap(y);
}
#endif // BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -1026,7 +1041,8 @@ inline void swap(static_vector<V, C1> & x, static_vector<V, C2> & y);
#else
template<typename V, std::size_t C1, std::size_t C2>
inline void swap(static_vector<V, C1> & x, static_vector<V, C2> & y)
inline void swap(static_vector<V, C1> & x, static_vector<V, C2> & y
, typename container_detail::enable_if_c< C1 != C2>::type * = 0)
{
x.swap(y);
}