EnTT 3.13.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
entt::adjacency_matrix< Category, Allocator > Class Template Reference

Basic implementation of a directed adjacency matrix. More...

#include <adjacency_matrix.hpp>

Public Types

using allocator_type = Allocator
 Allocator type.
 
using size_type = std::size_t
 Unsigned integer type.
 
using vertex_type = size_type
 Vertex type.
 
using edge_type = std::pair< vertex_type, vertex_type >
 Edge type.
 
using vertex_iterator = iota_iterator< vertex_type >
 Vertex iterator type.
 
using edge_iterator = internal::edge_iterator< typename container_type::const_iterator >
 Edge iterator type.
 
using out_edge_iterator = edge_iterator
 Out edge iterator type.
 
using in_edge_iterator = edge_iterator
 In edge iterator type.
 
using graph_category = Category
 Graph category tag.
 

Public Member Functions

 adjacency_matrix () noexcept(noexcept(allocator_type{}))
 Default constructor.
 
 adjacency_matrix (const allocator_type &allocator) noexcept
 Constructs an empty container with a given allocator.
 
 adjacency_matrix (const size_type vertices, const allocator_type &allocator=allocator_type{})
 Constructs an empty container with a given allocator and user supplied number of vertices.
 
 adjacency_matrix (const adjacency_matrix &other)
 Copy constructor.
 
 adjacency_matrix (const adjacency_matrix &other, const allocator_type &allocator)
 Allocator-extended copy constructor.
 
 adjacency_matrix (adjacency_matrix &&other) noexcept
 Move constructor.
 
 adjacency_matrix (adjacency_matrix &&other, const allocator_type &allocator)
 Allocator-extended move constructor.
 
adjacency_matrixoperator= (const adjacency_matrix &other)
 Default copy assignment operator.
 
adjacency_matrixoperator= (adjacency_matrix &&other) noexcept
 Default move assignment operator.
 
constexpr allocator_type get_allocator () const noexcept
 Returns the associated allocator.
 
void clear () noexcept
 Clears the adjacency matrix.
 
void swap (adjacency_matrix &other)
 Exchanges the contents with those of a given adjacency matrix.
 
size_type size () const noexcept
 Returns the number of vertices.
 
iterable_adaptor< vertex_iteratorvertices () const noexcept
 Returns an iterable object to visit all vertices of a matrix.
 
iterable_adaptor< edge_iteratoredges () const noexcept
 Returns an iterable object to visit all edges of a matrix.
 
iterable_adaptor< out_edge_iteratorout_edges (const vertex_type vertex) const noexcept
 Returns an iterable object to visit all out edges of a vertex.
 
iterable_adaptor< in_edge_iteratorin_edges (const vertex_type vertex) const noexcept
 Returns an iterable object to visit all in edges of a vertex.
 
void resize (const size_type vertices)
 Resizes an adjacency matrix.
 
std::pair< edge_iterator, bool > insert (const vertex_type lhs, const vertex_type rhs)
 Inserts an edge into the adjacency matrix, if it does not exist.
 
size_type erase (const vertex_type lhs, const vertex_type rhs)
 Removes the edge associated with a pair of given vertices.
 
bool contains (const vertex_type lhs, const vertex_type rhs) const
 Checks if an adjacency matrix contains a given edge.
 

Detailed Description

template<typename Category, typename Allocator>
class entt::adjacency_matrix< Category, Allocator >

Basic implementation of a directed adjacency matrix.

Template Parameters
CategoryEither a directed or undirected category tag.
AllocatorType of allocator used to manage memory and elements.

Definition at line 95 of file adjacency_matrix.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::allocator_type = Allocator

Allocator type.

Definition at line 103 of file adjacency_matrix.hpp.

◆ edge_iterator

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::edge_iterator = internal::edge_iterator<typename container_type::const_iterator>

Edge iterator type.

Definition at line 113 of file adjacency_matrix.hpp.

◆ edge_type

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::edge_type = std::pair<vertex_type, vertex_type>

Edge type.

Definition at line 109 of file adjacency_matrix.hpp.

◆ graph_category

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::graph_category = Category

Graph category tag.

Definition at line 119 of file adjacency_matrix.hpp.

◆ in_edge_iterator

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::in_edge_iterator = edge_iterator

In edge iterator type.

Definition at line 117 of file adjacency_matrix.hpp.

◆ out_edge_iterator

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::out_edge_iterator = edge_iterator

Out edge iterator type.

Definition at line 115 of file adjacency_matrix.hpp.

◆ size_type

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::size_type = std::size_t

Unsigned integer type.

Definition at line 105 of file adjacency_matrix.hpp.

◆ vertex_iterator

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::vertex_iterator = iota_iterator<vertex_type>

Vertex iterator type.

Definition at line 111 of file adjacency_matrix.hpp.

◆ vertex_type

template<typename Category , typename Allocator >
using entt::adjacency_matrix< Category, Allocator >::vertex_type = size_type

Vertex type.

Definition at line 107 of file adjacency_matrix.hpp.

Constructor & Destructor Documentation

◆ adjacency_matrix() [1/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( )
inlinenoexcept

Default constructor.

Definition at line 122 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [2/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( const allocator_type allocator)
inlineexplicitnoexcept

Constructs an empty container with a given allocator.

Parameters
allocatorThe allocator to use.

Definition at line 129 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [3/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( const size_type  vertices,
const allocator_type allocator = allocator_type{} 
)
inline

Constructs an empty container with a given allocator and user supplied number of vertices.

Parameters
verticesNumber of vertices.
allocatorThe allocator to use.

Definition at line 138 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [4/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( const adjacency_matrix< Category, Allocator > &  other)
inline

Copy constructor.

Parameters
otherThe instance to copy from.

Definition at line 146 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [5/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( const adjacency_matrix< Category, Allocator > &  other,
const allocator_type allocator 
)
inline

Allocator-extended copy constructor.

Parameters
otherThe instance to copy from.
allocatorThe allocator to use.

Definition at line 154 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [6/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( adjacency_matrix< Category, Allocator > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe instance to move from.

Definition at line 162 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [7/7]

template<typename Category , typename Allocator >
entt::adjacency_matrix< Category, Allocator >::adjacency_matrix ( adjacency_matrix< Category, Allocator > &&  other,
const allocator_type allocator 
)
inline

Allocator-extended move constructor.

Parameters
otherThe instance to move from.
allocatorThe allocator to use.

Definition at line 170 of file adjacency_matrix.hpp.

Member Function Documentation

◆ clear()

template<typename Category , typename Allocator >
void entt::adjacency_matrix< Category, Allocator >::clear ( )
inlinenoexcept

Clears the adjacency matrix.

Definition at line 205 of file adjacency_matrix.hpp.

◆ contains()

template<typename Category , typename Allocator >
bool entt::adjacency_matrix< Category, Allocator >::contains ( const vertex_type  lhs,
const vertex_type  rhs 
) const
inline

Checks if an adjacency matrix contains a given edge.

Parameters
lhsThe left hand vertex of the edge.
rhsThe right hand vertex of the edge.
Returns
True if there is such an edge, false otherwise.

Definition at line 329 of file adjacency_matrix.hpp.

◆ edges()

template<typename Category , typename Allocator >
iterable_adaptor< edge_iterator > entt::adjacency_matrix< Category, Allocator >::edges ( ) const
inlinenoexcept

Returns an iterable object to visit all edges of a matrix.

Returns
An iterable object to visit all edges of a matrix.

Definition at line 240 of file adjacency_matrix.hpp.

◆ erase()

template<typename Category , typename Allocator >
size_type entt::adjacency_matrix< Category, Allocator >::erase ( const vertex_type  lhs,
const vertex_type  rhs 
)
inline

Removes the edge associated with a pair of given vertices.

Parameters
lhsThe left hand vertex of the edge.
rhsThe right hand vertex of the edge.
Returns
Number of elements removed (either 0 or 1).

Definition at line 311 of file adjacency_matrix.hpp.

◆ get_allocator()

template<typename Category , typename Allocator >
constexpr allocator_type entt::adjacency_matrix< Category, Allocator >::get_allocator ( ) const
inlineconstexprnoexcept

Returns the associated allocator.

Returns
The associated allocator.

Definition at line 200 of file adjacency_matrix.hpp.

◆ in_edges()

template<typename Category , typename Allocator >
iterable_adaptor< in_edge_iterator > entt::adjacency_matrix< Category, Allocator >::in_edges ( const vertex_type  vertex) const
inlinenoexcept

Returns an iterable object to visit all in edges of a vertex.

Parameters
vertexThe vertex of which to return all in edges.
Returns
An iterable object to visit all in edges of a vertex.

Definition at line 263 of file adjacency_matrix.hpp.

◆ insert()

template<typename Category , typename Allocator >
std::pair< edge_iterator, bool > entt::adjacency_matrix< Category, Allocator >::insert ( const vertex_type  lhs,
const vertex_type  rhs 
)
inline

Inserts an edge into the adjacency matrix, if it does not exist.

Parameters
lhsThe left hand vertex of the edge.
rhsThe right hand vertex of the edge.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool denoting whether the insertion took place.

Definition at line 292 of file adjacency_matrix.hpp.

◆ operator=() [1/2]

template<typename Category , typename Allocator >
adjacency_matrix & entt::adjacency_matrix< Category, Allocator >::operator= ( adjacency_matrix< Category, Allocator > &&  other)
inlinenoexcept

Default move assignment operator.

Parameters
otherThe instance to move from.
Returns
This container.

Definition at line 190 of file adjacency_matrix.hpp.

◆ operator=() [2/2]

template<typename Category , typename Allocator >
adjacency_matrix & entt::adjacency_matrix< Category, Allocator >::operator= ( const adjacency_matrix< Category, Allocator > &  other)
inline

Default copy assignment operator.

Parameters
otherThe instance to copy from.
Returns
This container.

Definition at line 179 of file adjacency_matrix.hpp.

◆ out_edges()

template<typename Category , typename Allocator >
iterable_adaptor< out_edge_iterator > entt::adjacency_matrix< Category, Allocator >::out_edges ( const vertex_type  vertex) const
inlinenoexcept

Returns an iterable object to visit all out edges of a vertex.

Parameters
vertexThe vertex of which to return all out edges.
Returns
An iterable object to visit all out edges of a vertex.

Definition at line 251 of file adjacency_matrix.hpp.

◆ resize()

template<typename Category , typename Allocator >
void entt::adjacency_matrix< Category, Allocator >::resize ( const size_type  vertices)
inline

Resizes an adjacency matrix.

Parameters
verticesThe new number of vertices.

Definition at line 274 of file adjacency_matrix.hpp.

◆ size()

template<typename Category , typename Allocator >
size_type entt::adjacency_matrix< Category, Allocator >::size ( ) const
inlinenoexcept

Returns the number of vertices.

Returns
The number of vertices.

Definition at line 224 of file adjacency_matrix.hpp.

◆ swap()

template<typename Category , typename Allocator >
void entt::adjacency_matrix< Category, Allocator >::swap ( adjacency_matrix< Category, Allocator > &  other)
inline

Exchanges the contents with those of a given adjacency matrix.

Parameters
otherAdjacency matrix to exchange the content with.

Definition at line 214 of file adjacency_matrix.hpp.

◆ vertices()

template<typename Category , typename Allocator >
iterable_adaptor< vertex_iterator > entt::adjacency_matrix< Category, Allocator >::vertices ( ) const
inlinenoexcept

Returns an iterable object to visit all vertices of a matrix.

Returns
An iterable object to visit all vertices of a matrix.

Definition at line 232 of file adjacency_matrix.hpp.


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