EnTT 3.14.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 &)=default
 Default copy constructor.
 
 adjacency_matrix (const adjacency_matrix &other, const allocator_type &allocator)
 Allocator-extended copy constructor.
 
 adjacency_matrix (adjacency_matrix &&) noexcept=default
 Default move constructor.
 
 adjacency_matrix (adjacency_matrix &&other, const allocator_type &allocator)
 Allocator-extended move constructor.
 
 ~adjacency_matrix ()=default
 Default destructor.
 
adjacency_matrixoperator= (const adjacency_matrix &)=default
 Default copy assignment operator.
 
adjacency_matrixoperator= (adjacency_matrix &&) noexcept=default
 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) noexcept
 Exchanges the contents with those of a given adjacency matrix.
 
bool empty () const noexcept
 Returns true if an adjacency matrix is empty, false otherwise.
 
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, boolinsert (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 91 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 99 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 109 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 105 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 115 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 113 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 111 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 101 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 107 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 103 of file adjacency_matrix.hpp.

Constructor & Destructor Documentation

◆ adjacency_matrix() [1/5]

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

Default constructor.

Definition at line 118 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [2/5]

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 126 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [3/5]

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 135 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [4/5]

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 147 of file adjacency_matrix.hpp.

◆ adjacency_matrix() [5/5]

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 159 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 187 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 324 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 235 of file adjacency_matrix.hpp.

◆ empty()

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

Returns true if an adjacency matrix is empty, false otherwise.

Warning
Potentially expensive, try to avoid it on hot paths.
Returns
True if the adjacency matrix is empty, false otherwise.

Definition at line 210 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 306 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 182 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 258 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 287 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 > && )
defaultnoexcept

Default move assignment operator.

Returns
This container.

◆ operator=() [2/2]

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

Default copy assignment operator.

Returns
This container.

◆ 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 246 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 269 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 219 of file adjacency_matrix.hpp.

◆ swap()

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

Exchanges the contents with those of a given adjacency matrix.

Parameters
otherAdjacency matrix to exchange the content with.

Definition at line 196 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 227 of file adjacency_matrix.hpp.


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