vg
tools for working with variation graphs
Classes | Public Member Functions | Public Attributes | List of all members
vg::VectorView< Item > Struct Template Reference

#include <utility.hpp>

Classes

struct  const_iterator
 Random access iterator. More...
 

Public Member Functions

 VectorView ()
 
 ~VectorView ()=default
 
 VectorView (const VectorView &other)=default
 
 VectorView (VectorView &&other)=default
 
VectorViewoperator= (const VectorView &other)=default
 
VectorViewoperator= (VectorView &&other)=default
 
 VectorView (const vector< Item > &items)
 
 VectorView (const vector< Item > &items, const vector< size_t > &indexes)
 
const Item & operator[] (size_t index) const
 
size_t backing_index (size_t index) const
 
size_t size () const
 
bool empty () const
 
void with_vector (const std::function< void(const vector< Item > &)> &callback) const
 
void with_vector (const std::function< void(vector< Item > &)> &callback)
 
const_iterator begin () const
 Get iterator to first item. More...
 
const_iterator end () const
 Get iterator to past-end item. More...
 

Public Attributes

const vector< Item > * items
 
const vector< size_t > * indexes
 

Detailed Description

template<typename Item>
struct vg::VectorView< Item >

We want to be able to operate on reordered subset of things without moving the originals, so we use this view over things stored in a vector.

Both the backing collection and the indexes must outlive the view.

Copyable and assignable, and default-constructable to an empty state.

Constructor & Destructor Documentation

◆ VectorView() [1/5]

template<typename Item >
vg::VectorView< Item >::VectorView ( )
inline

◆ ~VectorView()

template<typename Item >
vg::VectorView< Item >::~VectorView ( )
default

◆ VectorView() [2/5]

template<typename Item >
vg::VectorView< Item >::VectorView ( const VectorView< Item > &  other)
default

◆ VectorView() [3/5]

template<typename Item >
vg::VectorView< Item >::VectorView ( VectorView< Item > &&  other)
default

◆ VectorView() [4/5]

template<typename Item >
vg::VectorView< Item >::VectorView ( const vector< Item > &  items)
inline

Make a VectorView of a whole vector. Provides an implicit conversion.

◆ VectorView() [5/5]

template<typename Item >
vg::VectorView< Item >::VectorView ( const vector< Item > &  items,
const vector< size_t > &  indexes 
)
inline

Make a VectorView of a reordered subset of a vector.

Member Function Documentation

◆ backing_index()

template<typename Item >
size_t vg::VectorView< Item >::backing_index ( size_t  index) const
inline

Get the backing index of an item by index.

◆ begin()

template<typename Item >
const_iterator vg::VectorView< Item >::begin ( ) const
inline

Get iterator to first item.

◆ empty()

template<typename Item >
bool vg::VectorView< Item >::empty ( ) const
inline

Determine if there are no items.

◆ end()

template<typename Item >
const_iterator vg::VectorView< Item >::end ( ) const
inline

Get iterator to past-end item.

◆ operator=() [1/2]

template<typename Item >
VectorView& vg::VectorView< Item >::operator= ( const VectorView< Item > &  other)
default

◆ operator=() [2/2]

template<typename Item >
VectorView& vg::VectorView< Item >::operator= ( VectorView< Item > &&  other)
default

◆ operator[]()

template<typename Item >
const Item& vg::VectorView< Item >::operator[] ( size_t  index) const
inline

Get an item by index.

◆ size()

template<typename Item >
size_t vg::VectorView< Item >::size ( ) const
inline

Get the total number of items.

◆ with_vector() [1/2]

template<typename Item >
void vg::VectorView< Item >::with_vector ( const std::function< void(const vector< Item > &)> &  callback) const
inline

Call the given callback with a dense and properly ordered vector of the items.

◆ with_vector() [2/2]

template<typename Item >
void vg::VectorView< Item >::with_vector ( const std::function< void(vector< Item > &)> &  callback)
inline

Call the given callback with a dense and properly ordered vector of the items, which can be modified. Modification will not be visible in the backing storage.

TODO: will this be called even when the const version could be more efficiently used?

Member Data Documentation

◆ indexes

template<typename Item >
const vector<size_t>* vg::VectorView< Item >::indexes

◆ items

template<typename Item >
const vector<Item>* vg::VectorView< Item >::items

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