Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve BlockVector to fix issues when sorting with recent versions of Boost #1502

Merged
merged 13 commits into from
Apr 23, 2020
Merged
Prev Previous commit
Next Next commit
Replaced TODO with function definitions without implementations
hakonsbm committed Apr 14, 2020
commit 31a596b244e1252b8f058aae0dc7668903b54109
71 changes: 69 additions & 2 deletions libnestutil/block_vector.h
Original file line number Diff line number Diff line change
@@ -29,6 +29,8 @@
#include <iterator>
#include <cassert>

#include "sliexceptions.h"

template < typename value_type_ >
class BlockVector;
template < typename value_type_, typename ref_, typename ptr_ >
@@ -260,8 +262,38 @@ class BlockVector
*/
int get_max_block_size() const;

// TODO: To make BlockVector a complete random access container, it should also implement
// max_size(), rbegin(), and rend().
/**
* @brief Returns the size() of the largest possible BlockVector.
*/
size_type max_size() const;

/**
* @brief Returns a read/write reverse iterator that points to the last
* element in the BlockVector. Iteration is done in reverse element
* order.
*/
reverse_iterator rbegin();

/**
* @brief Returns a read-only (constant) reverse iterator that points to
* the last element in the BlockVector. Iteration is done in reverse
* element order.
*/
reverse_iterator rbegin() const;

/**
* @brief Returns a read/write reverse iterator that points to one
* before the first element in the BlockVector. Iteration is done in
* reverse element order.
*/
reverse_iterator rend();

/**
* @brief Returns a read-only (constant) reverse iterator that points to
* one before the first element in the BlockVector. Iteration is done in
* reverse element order.
*/
reverse_iterator rend() const;

private:
//! Vector holding blocks containing data.
@@ -479,6 +511,41 @@ BlockVector< value_type_ >::get_max_block_size() const
return max_block_size;
}

template < typename value_type_ >
inline typename BlockVector< value_type_ >::size_type
BlockVector< value_type_ >::max_size() const
{
throw NotImplemented( "BlockVector max_size() is not implemented." );
}

template < typename value_type_ >
inline typename BlockVector< value_type_ >::reverse_iterator
BlockVector< value_type_ >::rbegin()
{
throw NotImplemented( "BlockVector rbegin() is not implemented." );
}

template < typename value_type_ >
inline typename BlockVector< value_type_ >::reverse_iterator
BlockVector< value_type_ >::rbegin() const
{
throw NotImplemented( "BlockVector rbegin() is not implemented." );
}

template < typename value_type_ >
inline typename BlockVector< value_type_ >::reverse_iterator
BlockVector< value_type_ >::rend()
{
throw NotImplemented( "BlockVector rend() is not implemented." );
}

template < typename value_type_ >
inline typename BlockVector< value_type_ >::reverse_iterator
BlockVector< value_type_ >::rend() const
{
throw NotImplemented( "BlockVector rend() is not implemented." );
}

/////////////////////////////////////////////////////////////
// BlockVector iterator method implementation //
/////////////////////////////////////////////////////////////