Ocean
Ocean::Subset Class Reference

This class implements subset functions. More...

Data Structures

class  InternalSubset
 This helper class implements a subset functions. More...
 

Static Public Member Functions

template<typename TIndex , typename T >
static std::vector< T > subset (const std::vector< T > &objects, const std::vector< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of an index vector holding the indices of all objects to be used. More...
 
template<typename TIndex , typename T >
static std::vector< T > subset (const std::vector< T > &objects, const std::set< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used. More...
 
template<typename TIndex , typename T >
static std::vector< T > invertedSubset (const std::vector< T > &objects, const std::unordered_set< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used. More...
 
template<typename TIndex , typename T >
static std::vector< T > invertedSubset (const std::vector< T > &objects, const std::set< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used. More...
 
template<typename TIndex , typename T >
static std::vector< T > subset (const T *objects, const size_t numberObjects, const TIndex *indices, const size_t numberIndices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used. More...
 
template<typename TIndex , typename T >
static std::vector< T > subset (const T *objects, const size_t numberObjects, const std::vector< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used. More...
 
template<typename TIndex , typename T >
static std::vector< T > subset (const T *objects, const size_t numberObjects, const std::set< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used. More...
 
template<typename TIndex >
static std::vector< TIndex > invertedIndices (const std::vector< TIndex > &indices, const size_t numberElements)
 Extracts the indices that are not given within a set indices. More...
 
template<typename TIndex >
static std::unordered_set< TIndex > invertedIndices (const std::unordered_set< TIndex > &indices, const size_t numberElements)
 Extracts the indices that are not given within a set indices. More...
 
template<typename TIndex >
static std::set< TIndex > invertedIndices (const std::set< TIndex > &indices, const size_t numberElements)
 Extracts the indices that are not given within a set indices. More...
 
template<typename TIndex , typename T >
static std::vector< T > invertedSubset (const T *objects, const size_t numberObjects, const std::unordered_set< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used. More...
 
template<typename TIndex , typename T >
static std::vector< T > invertedSubset (const T *objects, const size_t numberObjects, const std::set< TIndex > &indices)
 Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used. More...
 
template<typename TIndex , uint8_t tValue>
static std::vector< uint8_t > indices2statements (const std::vector< TIndex > &indices, const size_t numberObjects)
 Converts object indices to an uint8_t vector holding statements for each object. More...
 
template<typename TIndex , uint8_t tValue>
static std::vector< uint8_t > indices2statements (const std::set< TIndex > &indices, const size_t numberObjects)
 Converts object indices to an uint8_t vector holding statements for each object. More...
 
template<typename TIndex , uint8_t tValue>
static std::vector< uint8_t > indices2statements (const std::unordered_set< TIndex > &indices, const size_t numberObjects)
 Converts object indices to an uint8_t vector holding statements for each object. More...
 
template<typename TIndex , uint8_t tValue>
static std::vector< uint8_t > indices2statements (const TIndex *indices, const size_t numberIndices, const size_t numberObjects)
 Converts object indices to an uint8_t vector holding statements for each object. More...
 
template<typename TIndex , uint8_t tValue>
static std::vector< TIndex > statements2indices (const std::vector< uint8_t > &statements)
 Converts an uint8_t vector holding statements for each object into object indices. More...
 
template<typename TIndex , uint8_t tValue>
static std::vector< TIndex > statements2indices (const uint8_t *statements, const size_t numberStatements)
 Converts an uint8_t vector holding statements for each object into object indices. More...
 
template<typename TKey , typename TElement >
static void correspondingElements (const std::map< TKey, TElement > &elementMapA, const std::map< TKey, TElement > &elementMapB, std::vector< TElement > &elementsA, std::vector< TElement > &elementsB)
 Determines corresponding element pairs from two sets of element maps. More...
 
template<typename TIterator >
static bool hasIntersectingElement (const TIterator &firstA, const TIterator &endA, const TIterator &firstB, const TIterator &endB)
 Determines whether two (ordered) sets have at least one intersecting element. More...
 
template<typename T >
static bool hasIntersectingElement (const std::set< T > &setA, const std::set< T > &setB)
 Determines whether two (ordered) sets have at least one intersecting element. More...
 
template<typename T >
static bool hasIntersectingElement (const std::vector< T > &sortedA, const std::vector< T > &sortedB)
 Determines whether two ordered vectors have at least one intersecting element. More...
 

Detailed Description

This class implements subset functions.

Member Function Documentation

◆ correspondingElements()

template<typename TKey , typename TElement >
void Ocean::Subset::correspondingElements ( const std::map< TKey, TElement > &  elementMapA,
const std::map< TKey, TElement > &  elementMapB,
std::vector< TElement > &  elementsA,
std::vector< TElement > &  elementsB 
)
static

Determines corresponding element pairs from two sets of element maps.

Two elements correspond with each other if they have the same key.

Parameters
elementMapAThe first map of elements
elementMapBThe second map of elements
elementsAThe resulting elements from the first map which have a corresponding element in the second map
elementsBThe resulting elements from the second map which have a corresponding element in the first map
Template Parameters
TKeyThe data type of each key
TElementThe data type of each element

◆ hasIntersectingElement() [1/3]

template<typename T >
bool Ocean::Subset::hasIntersectingElement ( const std::set< T > &  setA,
const std::set< T > &  setB 
)
inlinestatic

Determines whether two (ordered) sets have at least one intersecting element.

Parameters
setAThe first set to check, can be empty
setBThe second set to check, can be empty
Returns
True, if so

◆ hasIntersectingElement() [2/3]

template<typename T >
bool Ocean::Subset::hasIntersectingElement ( const std::vector< T > &  sortedA,
const std::vector< T > &  sortedB 
)
inlinestatic

Determines whether two ordered vectors have at least one intersecting element.

Parameters
sortedAThe first vector to check, can be empty
sortedBThe second vector to check, can be empty
Returns
True, if so

◆ hasIntersectingElement() [3/3]

template<typename TIterator >
bool Ocean::Subset::hasIntersectingElement ( const TIterator &  firstA,
const TIterator &  endA,
const TIterator &  firstB,
const TIterator &  endB 
)
static

Determines whether two (ordered) sets have at least one intersecting element.

Both input sets must be in ascending order.

Parameters
firstAThe iterator to the first element in the first set
endAThe iterator to the (exclusive) element after the last element in the first set
firstBThe iterator to the first element in the second set
endBThe iterator to the (exclusive) element after the last element in the second set
Returns
True, if so

◆ indices2statements() [1/4]

template<typename TIndex , uint8_t tValue>
std::vector< uint8_t > Ocean::Subset::indices2statements ( const std::set< TIndex > &  indices,
const size_t  numberObjects 
)
inlinestatic

Converts object indices to an uint8_t vector holding statements for each object.

Parameters
indicesIndices defining the subset of the objects, with range [0, numberObjects)
numberObjectsNumber of objects that can be addressed by the indices
Returns
Resulting boolean statements
Template Parameters
TIndexData type of the index elements
tValueValue for objects that are defined in the indices, the inverse value is applied otherwise

◆ indices2statements() [2/4]

template<typename TIndex , uint8_t tValue>
std::vector< uint8_t > Ocean::Subset::indices2statements ( const std::unordered_set< TIndex > &  indices,
const size_t  numberObjects 
)
inlinestatic

Converts object indices to an uint8_t vector holding statements for each object.

Parameters
indicesIndices defining the subset of the objects, with range [0, numberObjects)
numberObjectsNumber of objects that can be addressed by the indices
Returns
Resulting boolean statements
Template Parameters
TIndexData type of the index elements
tValueValue for objects that are defined in the indices, the inverse value is applied otherwise

◆ indices2statements() [3/4]

template<typename TIndex , uint8_t tValue>
std::vector< uint8_t > Ocean::Subset::indices2statements ( const std::vector< TIndex > &  indices,
const size_t  numberObjects 
)
inlinestatic

Converts object indices to an uint8_t vector holding statements for each object.

Parameters
indicesIndices defining the subset of the objects, with range [0, numberObjects)
numberObjectsNumber of objects that can be addressed by the indices
Returns
Resulting boolean statements
Template Parameters
TIndexData type of the index elements
tValueValue for objects that are defined in the indices, the inverse value is applied otherwise

◆ indices2statements() [4/4]

template<typename TIndex , uint8_t tValue>
std::vector< uint8_t > Ocean::Subset::indices2statements ( const TIndex *  indices,
const size_t  numberIndices,
const size_t  numberObjects 
)
inlinestatic

Converts object indices to an uint8_t vector holding statements for each object.

Parameters
indicesIndices defining the subset of the objects, with range [0, numberObjects)
numberIndicesNumber of provided indices
numberObjectsNumber of objects that can be addressed by the indices
Returns
Resulting boolean statements
Template Parameters
TIndexData type of the index elements
tValueValue for objects that are defined in the indices, the inverse value is applied otherwise

◆ invertedIndices() [1/3]

template<typename TIndex >
std::set< TIndex > Ocean::Subset::invertedIndices ( const std::set< TIndex > &  indices,
const size_t  numberElements 
)
static

Extracts the indices that are not given within a set indices.

Parameters
indicesThe set of given indices, the resulting indices will not contain any of these indices, can contain indices with range [0, maximalIndex]
numberElementsThe number of possible elements defining the entire range of possible indices: [0, numberElements)
Template Parameters
TIndexData type of the index elements

◆ invertedIndices() [2/3]

template<typename TIndex >
std::unordered_set< TIndex > Ocean::Subset::invertedIndices ( const std::unordered_set< TIndex > &  indices,
const size_t  numberElements 
)
static

Extracts the indices that are not given within a set indices.

Parameters
indicesThe set of given indices, the resulting indices will not contain any of these indices, can contain indices with range [0, maximalIndex]
numberElementsThe number of possible elements defining the entire range of possible indices: [0, numberElements)
Template Parameters
TIndexData type of the index elements

◆ invertedIndices() [3/3]

template<typename TIndex >
std::vector< TIndex > Ocean::Subset::invertedIndices ( const std::vector< TIndex > &  indices,
const size_t  numberElements 
)
static

Extracts the indices that are not given within a set indices.

Parameters
indicesThe set of given indices, the resulting indices will not contain any of these indices, can contain indices with range [0, maximalIndex]
numberElementsThe number of possible elements defining the entire range of possible indices: [0, numberElements)
Template Parameters
TIndexData type of the index elements

◆ invertedSubset() [1/4]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::invertedSubset ( const std::vector< T > &  objects,
const std::set< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used.

Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
indicesIndices defining the inverted subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ invertedSubset() [2/4]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::invertedSubset ( const std::vector< T > &  objects,
const std::unordered_set< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used.

Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
indicesIndices defining the inverted subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ invertedSubset() [3/4]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::invertedSubset ( const T *  objects,
const size_t  numberObjects,
const std::set< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used.

Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
numberObjectsNumber of given objects
indicesIndices defining the inverted subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ invertedSubset() [4/4]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::invertedSubset ( const T *  objects,
const size_t  numberObjects,
const std::unordered_set< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be not used.

Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
numberObjectsNumber of given objects
indicesIndices defining the inverted subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ statements2indices() [1/2]

template<typename TIndex , uint8_t tValue>
std::vector< TIndex > Ocean::Subset::statements2indices ( const std::vector< uint8_t > &  statements)
inlinestatic

Converts an uint8_t vector holding statements for each object into object indices.

Parameters
statementsBoolean statement for each object
Returns
Resulting object indices
Template Parameters
TIndexData type of the index elements
tValueValue for objects that will be defined in the indices

◆ statements2indices() [2/2]

template<typename TIndex , uint8_t tValue>
std::vector< TIndex > Ocean::Subset::statements2indices ( const uint8_t *  statements,
const size_t  numberStatements 
)
inlinestatic

Converts an uint8_t vector holding statements for each object into object indices.

Parameters
statementsBoolean statement for each object
numberStatementsNumber of statements
Returns
Resulting object indices
Template Parameters
TIndexData type of the index elements
tValueValue for objects that will be defined in the indices

◆ subset() [1/5]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::subset ( const std::vector< T > &  objects,
const std::set< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used.

Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
indicesIndices defining the subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ subset() [2/5]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::subset ( const std::vector< T > &  objects,
const std::vector< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of an index vector holding the indices of all objects to be used.

If the index data type is an uint8_t, than the (boolean != 0u) statement is used to use the corresponding object or not.
Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
indicesIndices defining the subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ subset() [3/5]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::subset ( const T *  objects,
const size_t  numberObjects,
const std::set< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used.

Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
numberObjectsNumber of given objects
indicesIndices defining the subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ subset() [4/5]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::subset ( const T *  objects,
const size_t  numberObjects,
const std::vector< TIndex > &  indices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used.

If the index data type is an uint8_t, than the (boolean != 0u) statement is used to use the corresponding object or not.
Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
numberObjectsNumber of given objects
indicesIndices defining the subset to be extracted
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

◆ subset() [5/5]

template<typename TIndex , typename T >
std::vector< T > Ocean::Subset::subset ( const T *  objects,
const size_t  numberObjects,
const TIndex *  indices,
const size_t  numberIndices 
)
inlinestatic

Extracts a subset of a given set of objects by usage of a set of indices of all objects to be used.

If the index data type is an uint8_t, than the (boolean != 0u) statement is used to use the corresponding object or not.
Beware: No range check is done! Thus, each index must not exceed the number of given objects.

Parameters
objectsEntire set of objects from that a subset will be extracted
numberObjectsNumber of given objects
indicesIndices defining the subset to be extracted
numberIndicesNumber of given indices
Returns
Resulting subset of the given objects
Template Parameters
TIndexData type of the index elements
TData type of the objects

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