Spicy
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
hilti::rt::Vector< T, Allocator > Class Template Reference

#include <vector.h>

Inheritance diagram for hilti::rt::Vector< T, Allocator >:

Public Types

using V = std::vector< T, Allocator >
 
using size_type = integer::safe< uint64_t >
 
using reference = T &
 
using const_reference = const T &
 
using iterator = vector::Iterator< T, Allocator >
 
using const_iterator = vector::ConstIterator< T, Allocator >
 
using C = std::shared_ptr< Vector * >
 

Public Member Functions

 Vector (const Vector &other)
 
 Vector (Vector &&other) noexcept
 
 Vector (std::initializer_list< T > init, const Allocator &alloc=Allocator())
 
const T & front () const
 
const T & back () const
 
void pop_back ()
 
const_iterator iteratorAt (uint64_t i) const
 
Vector< T > sub (uint64_t start, uint64_t end) const
 
Vector< T > sub (uint64_t end) const
 
Vectoroperator= (const Vector &other)
 
Vectoroperator= (Vector &&other) noexcept
 
const T & operator[] (uint64_t i) const &
 
operator[] (uint64_t i) &&
 
T & operator[] (uint64_t i) &
 
void assign (uint64_t i, T x)
 
Vector operator+ (const Vector &other) const
 
Vectoroperator+= (const Vector &other)
 
iterator insert (iterator pos, const T &value)
 
auto begin ()
 
auto end ()
 
auto begin () const
 
auto end () const
 
auto cbegin () const
 
auto cend () const
 
size_type size () const
 

Public Attributes

_control = std::make_shared<Vector<T, Allocator>*>(this)
 

Friends

bool operator== (const Vector &a, const Vector &b)
 

Detailed Description

template<typename T, typename Allocator>
class hilti::rt::Vector< T, Allocator >

HILTI's Vector is a std::vector-like type with additional safety guarantees.

In particular it guarantees that

If not otherwise specified, member functions have the semantics of std::vector member functions.

Member Function Documentation

◆ back()

template<typename T, typename Allocator>
const T& hilti::rt::Vector< T, Allocator >::back ( ) const
inline

Returns the last element of the vector.

Returns
a reference to the last element
Exceptions
<tt>IndexError</tt>if the Vector is empty

◆ front()

template<typename T, typename Allocator>
const T& hilti::rt::Vector< T, Allocator >::front ( ) const
inline

Returns the last element of the vector.

Returns
a reference to the last element
Exceptions
<tt>IndexError</tt>if the Vector is empty

◆ insert()

template<typename T, typename Allocator>
iterator hilti::rt::Vector< T, Allocator >::insert ( iterator  pos,
const T &  value 
)
inline

Inserts value before a given position.

Parameters
positerator to the position preceding the inserted value
valuevalue to insert
Returns
iterator pointing to the inserted element

◆ iteratorAt()

template<typename T, typename Allocator>
const_iterator hilti::rt::Vector< T, Allocator >::iteratorAt ( uint64_t  i) const
inline

Returns an iterator referring to a specific element.

Parameters
iindex of element
Exceptions
<tt>IndexError</tt>if the i is out of range.

◆ operator+()

template<typename T, typename Allocator>
Vector hilti::rt::Vector< T, Allocator >::operator+ ( const Vector< T, Allocator > &  other) const
inline

Concatenates this Vector and another Vector.

Parameters
otherthe other Vector to append
Returns
the concatenation of this Vector and the other Vector

◆ operator+=()

template<typename T, typename Allocator>
Vector& hilti::rt::Vector< T, Allocator >::operator+= ( const Vector< T, Allocator > &  other)
inline

Appends a Vector in place.

Parameters
otherthe Vector to append
Returns
a reference to the modified Vector

◆ operator=() [1/2]

template<typename T, typename Allocator>
Vector& hilti::rt::Vector< T, Allocator >::operator= ( const Vector< T, Allocator > &  other)
inline

Replaces the contents of this Vector with another Vector.

In contrast to assignments of std::vector iterators remain valid and after assignment will point to positions in the assigned vector.

Parameters
otherthe Vector to assign
Returns
a reference to the changed Vector

◆ operator=() [2/2]

template<typename T, typename Allocator>
Vector& hilti::rt::Vector< T, Allocator >::operator= ( Vector< T, Allocator > &&  other)
inlinenoexcept

Replaces the contents of this Vector with another Vector.

In contrast to assignments of std::vector iterators remain valid and after assignment will point to positions in the assigned vector.

Parameters
otherthe Vector to assign
Returns
a reference to the changed Vector

◆ operator[]() [1/3]

template<typename T, typename Allocator>
const T& hilti::rt::Vector< T, Allocator >::operator[] ( uint64_t  i) const &
inline

Accesses specified element.

Parameters
iposition of the element to return
Returns
a reference to the element
Exceptions
<tt>IndexError</tt>if the position is out of bounds.

◆ operator[]() [2/3]

template<typename T, typename Allocator>
T hilti::rt::Vector< T, Allocator >::operator[] ( uint64_t  i) &&
inline

Accesses specified element.

Parameters
iposition of the element to return
Returns
the element
Exceptions
<tt>IndexError</tt>if the position is out of bounds.

◆ operator[]() [3/3]

template<typename T, typename Allocator>
T& hilti::rt::Vector< T, Allocator >::operator[] ( uint64_t  i) &
inline

Accesses specified element.

Parameters
iposition of the element to return
Returns
a reference to the element
Exceptions
<tt>IndexError</tt>if the position is out of bounds.

◆ pop_back()

template<typename T, typename Allocator>
void hilti::rt::Vector< T, Allocator >::pop_back ( )
inline

Removes the last element of the vector.

Exceptions
<tt>IndexError</tt>if the Vector is empty

◆ sub() [1/2]

template<typename T, typename Allocator>
Vector<T> hilti::rt::Vector< T, Allocator >::sub ( uint64_t  start,
uint64_t  end 
) const
inline

Extracts a subsequence from the vector.

Parameters
fromstart index
endend index (not including)
Returns
new vector with a copy of the range's elements

◆ sub() [2/2]

template<typename T, typename Allocator>
Vector<T> hilti::rt::Vector< T, Allocator >::sub ( uint64_t  end) const
inline

Extracts a subsequence from the vector.

Parameters
endend index (not including)
Returns
new vector with a copy of the elements from the beginning to end

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