KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
|
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data. More...
#include <pointer_vector_set.h>
Public Types | |
Iterators | |
using | iterator = boost::indirect_iterator< typename TContainerType::iterator > |
using | const_iterator = boost::indirect_iterator< typename TContainerType::const_iterator > |
using | reverse_iterator = boost::indirect_iterator< typename TContainerType::reverse_iterator > |
using | const_reverse_iterator = boost::indirect_iterator< typename TContainerType::const_reverse_iterator > |
Other definitions | |
using | size_type = typename TContainerType::size_type |
using | ptr_iterator = typename TContainerType::iterator |
using | ptr_const_iterator = typename TContainerType::const_iterator |
using | ptr_reverse_iterator = typename TContainerType::reverse_iterator |
using | ptr_const_reverse_iterator = typename TContainerType::const_reverse_iterator |
using | difference_type = typename TContainerType::difference_type |
Public Member Functions | |
Life Cycle | |
PointerVectorSet () | |
Default constructor. More... | |
template<class TInputIteratorType > | |
PointerVectorSet (TInputIteratorType First, TInputIteratorType Last, size_type NewMaxBufferSize=1) | |
Constructs a PointerVectorSet from a range of elements. More... | |
PointerVectorSet (const PointerVectorSet &rOther) | |
Copy constructor for PointerVectorSet. More... | |
PointerVectorSet (const TContainerType &rContainer) | |
Constructs a PointerVectorSet from a container. More... | |
~PointerVectorSet () | |
Destructor. More... | |
Operators | |
PointerVectorSet & | operator= (const PointerVectorSet &rOther) |
Assignment operator for PointerVectorSet. More... | |
TDataType & | operator[] (const key_type &Key) |
Accesses an element by key and returns a reference. More... | |
pointer & | operator() (const key_type &Key) |
Function for inserting or retrieving a pointer associated with a key. More... | |
bool | operator== (const PointerVectorSet &r) const noexcept |
Equality comparison operator for two PointerVectorSet objects. More... | |
bool | operator< (const PointerVectorSet &r) const noexcept |
Less than comparison operator for two PointerVectorSet objects. More... | |
Operations | |
iterator | begin () |
Returns an iterator pointing to the beginning of the container. More... | |
const_iterator | begin () const |
Returns a constant iterator pointing to the beginning of the container. More... | |
const_iterator | cbegin () |
Returns a constant iterator pointing to the beginning of the container. More... | |
const_iterator | cbegin () const |
Returns a constant iterator pointing to the beginning of the container. More... | |
iterator | end () |
Returns an iterator pointing to the end of the container. More... | |
const_iterator | end () const |
Returns a constant iterator pointing to the end of the container. More... | |
const_iterator | cend () |
Returns a constant iterator pointing to the end of the container. More... | |
const_iterator | cend () const |
Returns a constant iterator pointing to the end of the container. More... | |
reverse_iterator | rbegin () |
Returns a reverse iterator pointing to the beginning of the container. More... | |
const_reverse_iterator | rbegin () const |
Returns a constant reverse iterator pointing to the beginning of the container. More... | |
reverse_iterator | rend () |
Returns a reverse iterator pointing to the end of the container. More... | |
const_reverse_iterator | rend () const |
Returns a constant reverse iterator pointing to the end of the container. More... | |
ptr_iterator | ptr_begin () |
Returns an iterator pointing to the beginning of the underlying data container. More... | |
ptr_const_iterator | ptr_begin () const |
Returns a constant iterator pointing to the beginning of the underlying data container. More... | |
ptr_iterator | ptr_end () |
Returns an iterator pointing to the end of the underlying data container. More... | |
ptr_const_iterator | ptr_end () const |
Returns a constant iterator pointing to the end of the underlying data container. More... | |
ptr_reverse_iterator | ptr_rbegin () |
Returns a reverse iterator pointing to the beginning of the underlying data container. More... | |
ptr_const_reverse_iterator | ptr_rbegin () const |
Returns a constant reverse iterator pointing to the beginning of the underlying data container. More... | |
ptr_reverse_iterator | ptr_rend () |
Returns a reverse iterator pointing to the end of the underlying data container. More... | |
ptr_const_reverse_iterator | ptr_rend () const |
Returns a constant reverse iterator pointing to the end of the underlying data container. More... | |
reference | front () noexcept |
Returns a reference to the first element in the container. More... | |
const_reference | front () const noexcept |
Returns a constant reference to the first element in the container. More... | |
reference | back () noexcept |
Returns a reference to the last element in the container. More... | |
const_reference | back () const noexcept |
Returns a constant reference to the last element in the container. More... | |
size_type | size () const |
Returns the number of elements in the container. More... | |
size_type | max_size () const |
Returns the maximum possible number of elements the container can hold. More... | |
key_compare | key_comp () const |
Returns the key comparison function used for ordering elements in the container. More... | |
void | swap (PointerVectorSet &rOther) |
Swaps the contents of this PointerVectorSet with another. More... | |
void | push_back (TPointerType x) |
Adds a pointer to the end of the set. More... | |
void | pop_back () |
Removes the last element from the set. More... | |
iterator | insert (iterator Position, const TPointerType pData) |
Inserts a pointer at the specified position. More... | |
template<class InputIterator > | |
void | insert (InputIterator First, InputIterator Last) |
Insert elements from a range of iterators. More... | |
iterator | erase (iterator pos) |
Erase an element at the specified position. More... | |
iterator | erase (iterator first, iterator last) |
Erase a range of elements defined by iterators. More... | |
iterator | erase (const key_type &k) |
Erase an element with the specified key. More... | |
void | clear () |
Clear the set, removing all elements. More... | |
iterator | find (const key_type &Key) |
Find an element with the specified key. More... | |
const_iterator | find (const key_type &Key) const |
Find an element with the specified key (const version). More... | |
size_type | count (const key_type &Key) |
Count the number of elements with the specified key. More... | |
void | reserve (int reservedsize) |
Reserves memory for a specified number of elements. More... | |
int | capacity () |
Get the current capacity of the underlying data container. More... | |
void | Sort () |
Sort the elements in the set. More... | |
void | Unique () |
Remove duplicate elements from the set. More... | |
Access | |
TContainerType & | GetContainer () |
const TContainerType & | GetContainer () const |
size_type | GetMaxBufferSize () const |
Get the maximum size of buffer used in the container. More... | |
void | SetMaxBufferSize (const size_type NewSize) |
Set the maximum size of buffer used in the container. More... | |
size_type | GetSortedPartSize () const |
Get the sorted part size of buffer used in the container. More... | |
void | SetSortedPartSize (const size_type NewSize) |
Set the sorted part size of buffer used in the container. More... | |
Inquiry | |
bool | empty () const |
Check if the data container is empty. More... | |
bool | IsSorted () const |
Check if the data container is sorted. More... | |
Input and output | |
std::string | Info () const |
Turn back information as a string. More... | |
void | PrintInfo (std::ostream &rOStream) const |
Print information about this object. More... | |
void | PrintData (std::ostream &rOStream) const |
Print object's data. More... | |
Type Definitions | |
using | key_type = typename std::remove_reference< decltype(std::declval< TGetKeyType >()(std::declval< TDataType >()))>::type |
Key type for searching in this container. More... | |
using | data_type = TDataType |
using | value_type = TDataType |
using | key_compare = TCompareType |
using | pointer = TPointerType |
using | reference = TDataType & |
using | const_reference = const TDataType & |
using | ContainerType = TContainerType |
KRATOS_CLASS_POINTER_DEFINITION (PointerVectorSet) | |
Pointer definition of PointerVectorSet. More... | |
Serialization | |
class | Serializer |
A sorted associative container similar to an STL set, but uses a vector to store pointers to its data.
The PointerVectorSet
is a sorted associative container that behaves like an STL set but employs a vector to store pointers to its data elements. Many of its methods are inspired by the Boost ptr_container library, with modifications to support shared pointers.
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::const_iterator = boost::indirect_iterator<typename TContainerType::const_iterator> |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::const_reference = const TDataType& |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::const_reverse_iterator = boost::indirect_iterator<typename TContainerType::const_reverse_iterator> |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::ContainerType = TContainerType |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::data_type = TDataType |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::difference_type = typename TContainerType::difference_type |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::iterator = boost::indirect_iterator<typename TContainerType::iterator> |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::key_compare = TCompareType |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::key_type = typename std::remove_reference<decltype(std::declval<TGetKeyType>()(std::declval<TDataType>()))>::type |
Key type for searching in this container.
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::pointer = TPointerType |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::ptr_const_iterator = typename TContainerType::const_iterator |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::ptr_const_reverse_iterator = typename TContainerType::const_reverse_iterator |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::ptr_iterator = typename TContainerType::iterator |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::ptr_reverse_iterator = typename TContainerType::reverse_iterator |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::reference = TDataType& |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::reverse_iterator = boost::indirect_iterator<typename TContainerType::reverse_iterator> |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::size_type = typename TContainerType::size_type |
using Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::value_type = TDataType |
|
inline |
Default constructor.
|
inline |
Constructs a PointerVectorSet from a range of elements.
This constructor initializes a PointerVectorSet with elements in the range [First, Last).
TInputIteratorType | The type of the input iterator. |
First | An input iterator pointing to the beginning of the range. |
Last | An input iterator pointing to the end of the range. |
NewMaxBufferSize | The maximum buffer size (default is 1). |
|
inline |
Copy constructor for PointerVectorSet.
rOther | The PointerVectorSet to copy from. |
|
inlineexplicit |
Constructs a PointerVectorSet from a container.
This constructor initializes a PointerVectorSet with elements from a container.
rContainer | The container to copy elements from. |
|
inline |
Destructor.
|
inlinenoexcept |
Returns a constant reference to the last element in the container.
|
inlinenoexcept |
Returns a reference to the last element in the container.
|
inline |
Returns an iterator pointing to the beginning of the container.
|
inline |
Returns a constant iterator pointing to the beginning of the container.
|
inline |
Get the current capacity of the underlying data container.
This function returns the current capacity of the underlying data container.
|
inline |
Returns a constant iterator pointing to the beginning of the container.
|
inline |
Returns a constant iterator pointing to the beginning of the container.
|
inline |
Returns a constant iterator pointing to the end of the container.
|
inline |
Returns a constant iterator pointing to the end of the container.
|
inline |
Clear the set, removing all elements.
This function clears the set by removing all elements, resetting mSortedPartSize
to zero, and setting mMaxBufferSize
to 1.
|
inline |
Count the number of elements with the specified key.
This function counts the number of elements with the specified key in the set. It returns 1 if the element is found and 0 if it's not found.
Key | The key to count. |
|
inline |
Check if the data container is empty.
This function checks if the data container, represented by the member variable mData, is empty.
|
inline |
Returns an iterator pointing to the end of the container.
|
inline |
Returns a constant iterator pointing to the end of the container.
|
inline |
Erase an element with the specified key.
This function erases an element with the specified key by first finding the element using the find
function and then erasing it using the erase(iterator)
function.
k | The key of the element to erase. |
end()
if the element with the specified key was not found.
|
inline |
Erase a range of elements defined by iterators.
This function erases a range of elements defined by the iterators first
and last
and updates mSortedPartSize
to match the size of the data container.
first | An iterator pointing to the beginning of the range to erase. |
last | An iterator pointing to the end of the range to erase. |
|
inline |
Erase an element at the specified position.
This function erases the element at the specified position and updates mSortedPartSize
to match the size of the data container. If the provided position is equal to end()
, it returns end()
.
pos | An iterator pointing to the position of the element to erase. |
|
inline |
Find an element with the specified key.
This function searches for an element with the specified key in the set. If the element is found, it returns an iterator to the found element. If the element is not found, it returns an iterator pointing to the end of the set.
Key | The key to search for. |
|
inline |
Find an element with the specified key (const version).
This function is a const version of find() and searches for an element with the specified key in the set. If the element is found, it returns a const_iterator to the found element. If the element is not found, it returns a const_iterator pointing to the end of the set.
Key | The key to search for. |
|
inlinenoexcept |
Returns a constant reference to the first element in the container.
|
inlinenoexcept |
Returns a reference to the first element in the container.
|
inline |
Gives a reference to underly normal container.
|
inline |
Gives a constant reference to underly normal container.
|
inline |
Get the maximum size of buffer used in the container.
|
inline |
Get the sorted part size of buffer used in the container.
|
inline |
Turn back information as a string.
|
inline |
Insert elements from a range of iterators.
This function inserts elements from a range defined by the iterators First
and Last
into the set. It uses the insert
function to insert each element.
First | An input iterator pointing to the beginning of the range to insert. |
Last | An input iterator pointing to the end of the range to insert. |
|
inline |
Inserts a pointer at the specified position.
This function inserts a given pointer at the specified position in the set. It also maintains the sorting order and updates mSortedPartSize if necessary.
Position | An iterator pointing to the position where the pointer should be inserted. |
pData | The pointer to be inserted. |
|
inline |
Check if the data container is sorted.
This function checks if the sorted portion of the data, indicated by the member variable mSortedPartSize, is equal to the total size of the data container mData. This is used to determine if the data is sorted.
|
inline |
Returns the key comparison function used for ordering elements in the container.
This function returns an instance of the key comparison function (TCompareType) used for ordering elements in the container.
Kratos::PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType >::KRATOS_CLASS_POINTER_DEFINITION | ( | PointerVectorSet< TDataType, TGetKeyType, TCompareType, TEqualType, TPointerType, TContainerType > | ) |
Pointer definition of PointerVectorSet.
|
inline |
Returns the maximum possible number of elements the container can hold.
|
inline |
Function for inserting or retrieving a pointer associated with a key.
This function allows you to insert or retrieve a pointer associated with a key in the set. If the key already exists in the set, it returns the corresponding pointer. If not, it inserts the key and a new pointer into the set and returns the newly inserted pointer.
Key | The key for which you want to insert or retrieve a pointer. |
|
inlinenoexcept |
Less than comparison operator for two PointerVectorSet objects.
This operator checks if one PointerVectorSet is less than another by comparing their elements using the CompareKey comparison function in a lexicographical order.
r | The PointerVectorSet to compare with. |
|
inline |
Assignment operator for PointerVectorSet.
Assigns the contents of another PointerVectorSet to this one.
rOther | The PointerVectorSet to assign from. |
|
inlinenoexcept |
Equality comparison operator for two PointerVectorSet objects.
This operator checks if two PointerVectorSet objects are equal by comparing their sizes and the equality of their elements using the EqualKeyTo comparison function.
r | The PointerVectorSet to compare with. |
|
inline |
Accesses an element by key and returns a reference.
This operator allows you to access an element in the PointerVectorSet by its key. If the key is not found, a new element with the provided key is inserted into the set.
Key | The key of the element to access or insert. |
|
inline |
Removes the last element from the set.
This function removes the last element (pointer) from the set and updates mSortedPartSize if necessary.
|
inline |
Print object's data.
|
inline |
Print information about this object.
|
inline |
Returns an iterator pointing to the beginning of the underlying data container.
|
inline |
Returns a constant iterator pointing to the beginning of the underlying data container.
|
inline |
Returns an iterator pointing to the end of the underlying data container.
|
inline |
Returns a constant iterator pointing to the end of the underlying data container.
|
inline |
Returns a reverse iterator pointing to the beginning of the underlying data container.
|
inline |
Returns a constant reverse iterator pointing to the beginning of the underlying data container.
|
inline |
Returns a reverse iterator pointing to the end of the underlying data container.
|
inline |
Returns a constant reverse iterator pointing to the end of the underlying data container.
|
inline |
Adds a pointer to the end of the set.
This function appends a given pointer to the end of the set.
x | The pointer to be added to the end of the set. |
|
inline |
Returns a reverse iterator pointing to the beginning of the container.
|
inline |
Returns a constant reverse iterator pointing to the beginning of the container.
|
inline |
Returns a reverse iterator pointing to the end of the container.
|
inline |
Returns a constant reverse iterator pointing to the end of the container.
|
inline |
Reserves memory for a specified number of elements.
This function reserves memory in the underlying data container for a specified number of elements.
reservedsize | The number of elements to reserve memory for. |
|
inline |
Set the maximum size of buffer used in the container.
This container uses a buffer which keep data unsorted. After buffer size arrived to the MaxBufferSize it will sort all container and empties buffer.
NewSize | Is the new buffer maximum size. |
|
inline |
Set the sorted part size of buffer used in the container.
NewSize | Is the new buffer maximum size. |
|
inline |
Returns the number of elements in the container.
|
inline |
Sort the elements in the set.
This function sorts the elements in the set using the CompareKey comparison function. After sorting, it updates mSortedPartSize to match the size of the data container.
|
inline |
Swaps the contents of this PointerVectorSet with another.
This function swaps the contents of this PointerVectorSet with another set, including mSortedPartSize, mMaxBufferSize, and mData.
rOther | The other PointerVectorSet to swap with. |
|
inline |
Remove duplicate elements from the set.
This function removes duplicate elements from the set using the EqualKeyTo comparison function. After removing duplicates, it updates mSortedPartSize to match the size of the data container.
|
friend |