raiigraph
C++ RAII for igraph data structures
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
raiigraph::Vector< Ns_ > Class Template Reference

Wrapper around igraph_vector_*_t objects with RAII behavior. More...

#include <Vector.hpp>

Public Types

typedef Ns_::igraph_type igraph_type
 
typedef Ns_::value_type value_type
 
typedef value_typereference
 
typedef const value_typeconst_reference
 
typedef igraph_integer_t size_type
 
typedef igraph_integer_t difference_type
 
typedef value_typeiterator
 
typedef const value_typeconst_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorreverse_const_iterator
 

Public Member Functions

 Vector ()
 
 Vector (size_type size, const value_type &val=value_type())
 
 Vector (igraph_type &&vector)
 
template<typename InputIterator , typename = decltype(*std::declval<InputIterator>())>
 Vector (InputIterator first, InputIterator last)
 
 Vector (const Vector< Ns_ > &other)
 
Vector< Ns_ > & operator= (const Vector< Ns_ > &other)
 
 Vector (Vector< Ns_ > &&other)
 
Vectoroperator= (Vector< Ns_ > &&other)
 
 ~Vector ()
 
igraph_bool_t empty () const
 
size_type size () const
 
constexpr size_type max_size () const
 
size_type capacity () const
 
void clear ()
 
void resize (size_type size, value_type val=value_type())
 
void reserve (size_type capacity)
 
void shrink_to_fit ()
 
void push_back (value_type val)
 
template<typename ... Args>
void emplace_back (Args &&... args)
 
void pop_back ()
 
iterator erase (iterator pos)
 
iterator erase (iterator first, iterator last)
 
iterator insert (iterator pos, value_type val)
 
template<typename ... Args>
iterator emplace (iterator pos, Args &&... args)
 
iterator insert (iterator pos, size_type n, value_type val)
 
template<typename InputIterator , typename = decltype(*std::declval<InputIterator>())>
iterator insert (iterator pos, InputIterator first, InputIterator last)
 
reference operator[] (igraph_integer_t i)
 
const_reference operator[] (igraph_integer_t i) const
 
reference back ()
 
const_reference back () const
 
reference front ()
 
const_reference front () const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
value_typedata ()
 
const value_typedata () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
reverse_const_iterator rbegin () const
 
reverse_const_iterator rend () const
 
reverse_const_iterator crbegin () const
 
reverse_const_iterator crend () const
 
 operator igraph_type * ()
 
 operator const igraph_type * () const
 
igraph_typeget ()
 
const igraph_typeget () const
 
void swap (Vector< Ns_ > &other)
 

Detailed Description

template<class Ns_>
class raiigraph::Vector< Ns_ >

Wrapper around igraph_vector_*_t objects with RAII behavior.

Template Parameters
Ns_Structure-based namespace with static methods, internal use only.

This class has ownership of the underlying igraph_vector_*_t object, handling both its initialization and destruction. Users should only pass instances of this class to igraph functions that accept an already-initialized vector. Users should not attempt to destroy the vector manually as this is done automatically when the Vector goes out of scope.

Member Typedef Documentation

◆ const_iterator

template<class Ns_ >
typedef const value_type* raiigraph::Vector< Ns_ >::const_iterator

Const iterator for the vector contents.

◆ const_reference

template<class Ns_ >
typedef const value_type& raiigraph::Vector< Ns_ >::const_reference

Type of a const reference to values inside the vector.

◆ difference_type

template<class Ns_ >
typedef igraph_integer_t raiigraph::Vector< Ns_ >::difference_type

Integer type for differences in positions within the vector.

◆ igraph_type

template<class Ns_ >
typedef Ns_::igraph_type raiigraph::Vector< Ns_ >::igraph_type

Type of the underlying igraph vector.

◆ iterator

template<class Ns_ >
typedef value_type* raiigraph::Vector< Ns_ >::iterator

Iterator for the vector contents.

◆ reference

template<class Ns_ >
typedef value_type& raiigraph::Vector< Ns_ >::reference

Type of the reference to values inside the vector.

◆ reverse_const_iterator

template<class Ns_ >
typedef std::reverse_iterator<const_iterator> raiigraph::Vector< Ns_ >::reverse_const_iterator

Reverse const iterator for the vector contents.

◆ reverse_iterator

template<class Ns_ >
typedef std::reverse_iterator<iterator> raiigraph::Vector< Ns_ >::reverse_iterator

Reverse iterator for the vector contents.

◆ size_type

Integer type for the size of the vector.

◆ value_type

template<class Ns_ >
typedef Ns_::value_type raiigraph::Vector< Ns_ >::value_type

Type of the values inside the vector.

Constructor & Destructor Documentation

◆ Vector() [1/6]

template<class Ns_ >
raiigraph::Vector< Ns_ >::Vector ( )
inline

Default constructor, creates an initialized vector of length 0.

◆ Vector() [2/6]

template<class Ns_ >
raiigraph::Vector< Ns_ >::Vector ( size_type  size,
const value_type val = value_type() 
)
inline
Parameters
sizeSize of the vector to create.
valValue to use to fill the vector.

◆ Vector() [3/6]

template<class Ns_ >
raiigraph::Vector< Ns_ >::Vector ( igraph_type &&  vector)
inline
Parameters
vectorAn initialized vector to take ownership of.

◆ Vector() [4/6]

template<class Ns_ >
template<typename InputIterator , typename = decltype(*std::declval<InputIterator>())>
raiigraph::Vector< Ns_ >::Vector ( InputIterator  first,
InputIterator  last 
)
inline
Template Parameters
InputIteratorIterator type that supports forward increments and subtraction.
Parameters
firstIterator to the start of a range.
lastIterator to the end of a range (i.e., past the final element in the range).

◆ Vector() [5/6]

template<class Ns_ >
raiigraph::Vector< Ns_ >::Vector ( const Vector< Ns_ > &  other)
inline
Parameters
otherVector to be copy-constructed from. This constructor will make a deep copy.

◆ Vector() [6/6]

template<class Ns_ >
raiigraph::Vector< Ns_ >::Vector ( Vector< Ns_ > &&  other)
inline
Parameters
otherVector to be move-constructed from. This constructor will leave other in a valid but unspecified state.

◆ ~Vector()

template<class Ns_ >
raiigraph::Vector< Ns_ >::~Vector ( )
inline

Destructor.

Member Function Documentation

◆ back() [1/2]

template<class Ns_ >
reference raiigraph::Vector< Ns_ >::back ( )
inline
Returns
Reference to the last element in the vector.

◆ back() [2/2]

template<class Ns_ >
const_reference raiigraph::Vector< Ns_ >::back ( ) const
inline
Returns
Const reference to the last element in the vector.

◆ begin() [1/2]

template<class Ns_ >
iterator raiigraph::Vector< Ns_ >::begin ( )
inline
Returns
Iterator to the start of this vector.

◆ begin() [2/2]

template<class Ns_ >
const_iterator raiigraph::Vector< Ns_ >::begin ( ) const
inline
Returns
Const iterator to the start of this vector.

◆ capacity()

template<class Ns_ >
size_type raiigraph::Vector< Ns_ >::capacity ( ) const
inline
Returns
Capacity of this vector.

◆ cbegin()

template<class Ns_ >
const_iterator raiigraph::Vector< Ns_ >::cbegin ( ) const
inline
Returns
Const iterator to the start of this vector.

◆ cend()

template<class Ns_ >
const_iterator raiigraph::Vector< Ns_ >::cend ( ) const
inline
Returns
Const iterator to the end of this vector.

◆ clear()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::clear ( )
inline

Clear this vector, leaving it with a size of zero.

◆ crbegin()

template<class Ns_ >
reverse_const_iterator raiigraph::Vector< Ns_ >::crbegin ( ) const
inline
Returns
Reverse const iterator to the last element of this vector.

◆ crend()

template<class Ns_ >
reverse_const_iterator raiigraph::Vector< Ns_ >::crend ( ) const
inline
Returns
Reverse const iterator to a location before the start of this vector.

◆ data() [1/2]

template<class Ns_ >
value_type * raiigraph::Vector< Ns_ >::data ( )
inline
Returns
Pointer to the start of this vector.

◆ data() [2/2]

template<class Ns_ >
const value_type * raiigraph::Vector< Ns_ >::data ( ) const
inline
Returns
Const pointer to the start of this vector.

◆ emplace()

template<class Ns_ >
template<typename ... Args>
iterator raiigraph::Vector< Ns_ >::emplace ( iterator  pos,
Args &&...  args 
)
inline

Construct and insert an element into the vector.

Parameters
posPosition at which to insert the new element.
argsArguments for the value_type constructor.
Returns
Iterator to the newly inserted element.

◆ emplace_back()

template<class Ns_ >
template<typename ... Args>
void raiigraph::Vector< Ns_ >::emplace_back ( Args &&...  args)
inline

Construct and add a new element to the end of the vector.

Parameters
argsArguments for the value_type constructor.

◆ empty()

template<class Ns_ >
igraph_bool_t raiigraph::Vector< Ns_ >::empty ( ) const
inline
Returns
Whether the vector is empty.

◆ end() [1/2]

template<class Ns_ >
iterator raiigraph::Vector< Ns_ >::end ( )
inline
Returns
Iterator to the end of this vector.

◆ end() [2/2]

template<class Ns_ >
const_iterator raiigraph::Vector< Ns_ >::end ( ) const
inline
Returns
Const iterator to the end of this vector.

◆ erase() [1/2]

template<class Ns_ >
iterator raiigraph::Vector< Ns_ >::erase ( iterator  first,
iterator  last 
)
inline

Erase an element from the vector.

Parameters
firstStart of the range of elements to remove.
lastEnd of the range of elements to remove.

◆ erase() [2/2]

template<class Ns_ >
iterator raiigraph::Vector< Ns_ >::erase ( iterator  pos)
inline

Erase an element from the vector.

Parameters
posPosition at which to erase the element.

◆ front() [1/2]

template<class Ns_ >
reference raiigraph::Vector< Ns_ >::front ( )
inline
Returns
Reference to the last element in the vector.

◆ front() [2/2]

template<class Ns_ >
const_reference raiigraph::Vector< Ns_ >::front ( ) const
inline
Returns
Const reference to the last element in the vector.

◆ get() [1/2]

template<class Ns_ >
igraph_type * raiigraph::Vector< Ns_ >::get ( )
inline
Returns
Pointer to the underlying igraph vector object. This is guaranteed to be non-NULL and initialized.

◆ get() [2/2]

template<class Ns_ >
const igraph_type * raiigraph::Vector< Ns_ >::get ( ) const
inline
Returns
Const pointer to the underlying igraph vector object. This is guaranteed to be non-NULL and initialized.

◆ insert() [1/3]

template<class Ns_ >
template<typename InputIterator , typename = decltype(*std::declval<InputIterator>())>
iterator raiigraph::Vector< Ns_ >::insert ( iterator  pos,
InputIterator  first,
InputIterator  last 
)
inline

Insert a sequence of elements into the vector.

Template Parameters
InputIteratorIterator type that supports forward increments and subtraction.
Parameters
posPosition at which to insert the new elements.
firstIterator to the start of a range.
lastIterator to the end of a range (i.e., past the final element in the range).
Returns
Iterator to the first newly inserted element.

◆ insert() [2/3]

template<class Ns_ >
iterator raiigraph::Vector< Ns_ >::insert ( iterator  pos,
size_type  n,
value_type  val 
)
inline

Insert multiple copies of an element into the vector.

Parameters
posPosition at which to insert the new elements.
nNumber of values to insert.
valValue to be inserted.
Returns
Iterator to the first newly inserted element.

◆ insert() [3/3]

template<class Ns_ >
iterator raiigraph::Vector< Ns_ >::insert ( iterator  pos,
value_type  val 
)
inline

Insert an element into the vector.

Parameters
posPosition at which to insert the new element.
valValue to be inserted.
Returns
Iterator to the newly inserted element.

◆ max_size()

template<class Ns_ >
constexpr size_type raiigraph::Vector< Ns_ >::max_size ( ) const
inlineconstexpr
Returns
Maximum size of this vector.

◆ operator const igraph_type *()

template<class Ns_ >
raiigraph::Vector< Ns_ >::operator const igraph_type * ( ) const
inline
Returns
Const pointer to the underlying igraph vector object. This is guaranteed to be non-NULL and initialized.

◆ operator igraph_type *()

template<class Ns_ >
raiigraph::Vector< Ns_ >::operator igraph_type * ( )
inline
Returns
Pointer to the underlying igraph vector object. This is guaranteed to be non-NULL and initialized.

◆ operator=() [1/2]

template<class Ns_ >
Vector< Ns_ > & raiigraph::Vector< Ns_ >::operator= ( const Vector< Ns_ > &  other)
inline
Parameters
otherVector to be copy-assigned from. This constructor will make a deep copy.

◆ operator=() [2/2]

template<class Ns_ >
Vector & raiigraph::Vector< Ns_ >::operator= ( Vector< Ns_ > &&  other)
inline
Parameters
otherVector to be move-assigned from. This constructor will leave other in a valid but unspecified state.

◆ operator[]() [1/2]

Parameters
iIndex on the vector.
Returns
Reference to the value at i.

◆ operator[]() [2/2]

Parameters
iIndex on the vector.
Returns
Const reference to the value at i.

◆ pop_back()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::pop_back ( )
inline

Remove an element from the end of the vector.

◆ push_back()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::push_back ( value_type  val)
inline

Add a new element to the end of the vector.

Parameters
valValue to be added.

◆ rbegin() [1/2]

template<class Ns_ >
reverse_iterator raiigraph::Vector< Ns_ >::rbegin ( )
inline
Returns
Reverse iterator to the last element of this vector.

◆ rbegin() [2/2]

template<class Ns_ >
reverse_const_iterator raiigraph::Vector< Ns_ >::rbegin ( ) const
inline
Returns
Reverse const iterator to the last element of this vector.

◆ rend() [1/2]

template<class Ns_ >
reverse_iterator raiigraph::Vector< Ns_ >::rend ( )
inline
Returns
Reverse iterator to a location before the start of this vector.

◆ rend() [2/2]

template<class Ns_ >
reverse_const_iterator raiigraph::Vector< Ns_ >::rend ( ) const
inline
Returns
Reverse const iterator to a location before the start of this vector.

◆ reserve()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::reserve ( size_type  capacity)
inline

Reserve the capacity of the vector.

Parameters
capacityCapacity of the vector.

◆ resize()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::resize ( size_type  size,
value_type  val = value_type() 
)
inline

Resize the vector to the specified size.

Parameters
sizeNew size of the vector.
valValue to use to fill the new elements, if size is greater than the current size.

◆ shrink_to_fit()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::shrink_to_fit ( )
inline

Shrink the capacity of the vector to fit the contents.

◆ size()

template<class Ns_ >
size_type raiigraph::Vector< Ns_ >::size ( ) const
inline
Returns
Size of the vector.

◆ swap()

template<class Ns_ >
void raiigraph::Vector< Ns_ >::swap ( Vector< Ns_ > &  other)
inline

Swap two vectors, maintaining the validity of existing pointers to each vector and its elements.

Parameters
otherVector to be swapped.

The documentation for this class was generated from the following file: