mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes
m::dyn_array< T > Struct Template Reference

Implements an array of dynamic but fixed size. More...

#include <ADT.hpp>

Collaboration diagram for m::dyn_array< T >:
[legend]

Public Types

using value_type = T
 
using size_type = std::size_t
 
using iterator = value_type *
 
using const_iterator = const value_type *
 

Public Member Functions

 dyn_array ()
 Constructs an array of size 0.
 
 dyn_array (std::size_t size)
 Constructs an array of size size.
 
template<typename InputIt >
 dyn_array (InputIt begin, InputIt end)
 Constructs an array with the elements in range [begin, end).
 
 dyn_array (const dyn_array &other)
 Copy-constructs an array.
 
 dyn_array (dyn_array &&)=default
 
dyn_arrayoperator= (dyn_array &&)=default
 
size_type size () const
 Returns the size of this array, i.e.
 
const value_typedata () const
 Returns a pointer to the beginning of the array.
 
value_typedata ()
 Returns a pointer to the beginning of the array.
 
const value_typeoperator[] (std::size_t pos) const
 Returns a reference to the element at position pos.
 
value_typeoperator[] (std::size_t pos)
 Returns a reference to the element at position pos.
 
const value_typeat (std::size_t pos) const
 Returns a reference to the element at position pos.
 
value_typeat (std::size_t pos)
 Returns a reference to the element at position pos.
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
bool operator== (const dyn_array &other) const
 Returns true iff the contents of this and other are equal, that is, they have the same number of elements and each element in this compares equal with the element in other at the same position.
 
bool operator!= (const dyn_array &other) const
 Returns false iff the contents of this and other are equal, that is, they have the same number of elements and each element in this compares equal with the element in other at the same position.
 

Private Attributes

std::unique_ptr< value_type[]> arr_
 
std::size_t size_
 

Detailed Description

template<typename T>
struct m::dyn_array< T >

Implements an array of dynamic but fixed size.

Definition at line 277 of file ADT.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T >
using m::dyn_array< T >::const_iterator = const value_type*

Definition at line 282 of file ADT.hpp.

◆ iterator

template<typename T >
using m::dyn_array< T >::iterator = value_type*

Definition at line 281 of file ADT.hpp.

◆ size_type

template<typename T >
using m::dyn_array< T >::size_type = std::size_t

Definition at line 280 of file ADT.hpp.

◆ value_type

template<typename T >
using m::dyn_array< T >::value_type = T

Definition at line 279 of file ADT.hpp.

Constructor & Destructor Documentation

◆ dyn_array() [1/5]

template<typename T >
m::dyn_array< T >::dyn_array ( )
inline

Constructs an array of size 0.

Definition at line 290 of file ADT.hpp.

◆ dyn_array() [2/5]

template<typename T >
m::dyn_array< T >::dyn_array ( std::size_t  size)
inlineexplicit

Constructs an array of size size.

Definition at line 293 of file ADT.hpp.

◆ dyn_array() [3/5]

template<typename T >
template<typename InputIt >
m::dyn_array< T >::dyn_array ( InputIt  begin,
InputIt  end 
)
inline

Constructs an array with the elements in range [begin, end).

The size of the array will be std::distance(begin, end).

Definition at line 301 of file ADT.hpp.

References m::dyn_array< T >::begin(), m::dyn_array< T >::data(), and m::dyn_array< T >::end().

◆ dyn_array() [4/5]

template<typename T >
m::dyn_array< T >::dyn_array ( const dyn_array< T > &  other)
inlineexplicit

Copy-constructs an array.

Definition at line 310 of file ADT.hpp.

References m::dyn_array< T >::data(), and m::dyn_array< T >::size().

◆ dyn_array() [5/5]

template<typename T >
m::dyn_array< T >::dyn_array ( dyn_array< T > &&  )
default

Member Function Documentation

◆ at() [1/2]

template<typename T >
value_type & m::dyn_array< T >::at ( std::size_t  pos)
inline

Returns a reference to the element at position pos.

Throws m::out_of_range if pos is out of bounds.

Definition at line 348 of file ADT.hpp.

References m::dyn_array< T >::size().

◆ at() [2/2]

template<typename T >
const value_type & m::dyn_array< T >::at ( std::size_t  pos) const
inline

Returns a reference to the element at position pos.

Throws m::out_of_range if pos is out of bounds.

Definition at line 341 of file ADT.hpp.

References m::dyn_array< T >::size().

◆ begin() [1/2]

template<typename T >
iterator m::dyn_array< T >::begin ( )
inline

Definition at line 354 of file ADT.hpp.

References m::dyn_array< T >::data().

Referenced by m::dyn_array< T >::cbegin(), and m::dyn_array< T >::dyn_array().

◆ begin() [2/2]

template<typename T >
const_iterator m::dyn_array< T >::begin ( ) const
inline

Definition at line 356 of file ADT.hpp.

References m::dyn_array< T >::data().

◆ cbegin()

template<typename T >
const_iterator m::dyn_array< T >::cbegin ( ) const
inline

Definition at line 358 of file ADT.hpp.

References m::dyn_array< T >::begin().

◆ cend()

template<typename T >
const_iterator m::dyn_array< T >::cend ( ) const
inline

Definition at line 359 of file ADT.hpp.

References m::dyn_array< T >::end().

◆ data() [1/2]

template<typename T >
value_type * m::dyn_array< T >::data ( )
inline

Returns a pointer to the beginning of the array.

Definition at line 326 of file ADT.hpp.

References m::dyn_array< T >::arr_.

◆ data() [2/2]

template<typename T >
const value_type * m::dyn_array< T >::data ( ) const
inline

Returns a pointer to the beginning of the array.

Definition at line 324 of file ADT.hpp.

References m::dyn_array< T >::arr_.

Referenced by m::dyn_array< T >::begin(), m::dyn_array< T >::dyn_array(), m::dyn_array< T >::end(), and m::dyn_array< T >::operator[]().

◆ end() [1/2]

template<typename T >
iterator m::dyn_array< T >::end ( )
inline

◆ end() [2/2]

template<typename T >
const_iterator m::dyn_array< T >::end ( ) const
inline

Definition at line 357 of file ADT.hpp.

References m::dyn_array< T >::data(), and m::dyn_array< T >::size().

◆ operator!=()

template<typename T >
bool m::dyn_array< T >::operator!= ( const dyn_array< T > &  other) const
inline

Returns false iff the contents of this and other are equal, that is, they have the same number of elements and each element in this compares equal with the element in other at the same position.

Definition at line 376 of file ADT.hpp.

References m::dyn_array< T >::operator==().

◆ operator=()

template<typename T >
dyn_array & m::dyn_array< T >::operator= ( dyn_array< T > &&  )
default

◆ operator==()

template<typename T >
bool m::dyn_array< T >::operator== ( const dyn_array< T > &  other) const
inline

Returns true iff the contents of this and other are equal, that is, they have the same number of elements and each element in this compares equal with the element in other at the same position.

Definition at line 363 of file ADT.hpp.

References m::dyn_array< T >::size().

Referenced by m::dyn_array< T >::operator!=().

◆ operator[]() [1/2]

template<typename T >
value_type & m::dyn_array< T >::operator[] ( std::size_t  pos)
inline

Returns a reference to the element at position pos.

Requires that pos is in bounds.

Definition at line 335 of file ADT.hpp.

References m::dyn_array< T >::data(), M_insist, and m::dyn_array< T >::size().

◆ operator[]() [2/2]

template<typename T >
const value_type & m::dyn_array< T >::operator[] ( std::size_t  pos) const
inline

Returns a reference to the element at position pos.

Requires that pos is in bounds.

Definition at line 329 of file ADT.hpp.

References m::dyn_array< T >::data(), M_insist, and m::dyn_array< T >::size().

◆ size()

template<typename T >
size_type m::dyn_array< T >::size ( ) const
inline

Returns the size of this array, i.e.

the number of elements.

Definition at line 321 of file ADT.hpp.

References m::dyn_array< T >::size_.

Referenced by m::dyn_array< T >::at(), m::dyn_array< T >::dyn_array(), m::dyn_array< T >::end(), m::dyn_array< T >::operator==(), and m::dyn_array< T >::operator[]().

Field Documentation

◆ arr_

template<typename T >
std::unique_ptr<value_type[]> m::dyn_array< T >::arr_
private

Definition at line 285 of file ADT.hpp.

Referenced by m::dyn_array< T >::data().

◆ size_

template<typename T >
std::size_t m::dyn_array< T >::size_
private

Definition at line 286 of file ADT.hpp.

Referenced by m::dyn_array< T >::size().


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