Murl::Field< DataType, COUNT > Class Template Reference

A generic field template class for fixed-size arrays. More...

#include "murl_field.h"

Public Types

using ValueType = DataType
 The template parameter value type.
 
using ConstIterator = const DataType *
 Definition of the const iterator.
 
using Iterator = DataType *
 Definition of the iterator.
 

Public Member Functions

 Field ()
 Default constructor.
 
 Field (const Field &other)
 Construct a field from an already existing one, performing a deep copy. More...
 
 ~Field ()
 Destroy the field and all of its contents.
 
void operator= (const Field &other)
 Assign the content of another field to this one, performing a deep copy. More...
 
DataType & Set (SInt32 index, const DataType &item)
 Initialize an item with a given item. More...
 
Bool Set (SInt32 index, const DataType &item, SInt32 count)
 Initialize a range of items with a given item. More...
 
void Fill (const DataType &item)
 Fill all items with a given item. More...
 
void Swap (SInt32 index1, SInt32 index2)
 Swap two field items. More...
 
SInt32 Find (const DataType &item) const
 Find the first occurrence of a given item in the field. More...
 
SInt32 Find (const DataType &item, SInt32 firstIndex) const
 Find the first occurrence of a given item in the field. More...
 
SInt32 FindLast (const DataType &item) const
 Find the last occurrence of a given item in the field. More...
 
SInt32 FindLast (const DataType &item, SInt32 lastIndex) const
 Find the last occurrence of a given item in the field. More...
 
DataType & Front ()
 Retrieve the first item from the field. More...
 
const DataType & Front () const
 Retrieve the first item from the field. More...
 
DataType & Back ()
 Retrieve the last item from the field. More...
 
const DataType & Back () const
 Retrieve the last item from the field. More...
 
DataType & Bottom ()
 Retrieve the first item from the field. More...
 
const DataType & Bottom () const
 Retrieve the first item from the field. More...
 
DataType & Top ()
 Retrieve the last item from the field. More...
 
const DataType & Top () const
 Retrieve the last item from the field. More...
 
DataType & At (SInt32 index)
 Retrieve the item at a given position from the field. More...
 
DataType & At (SInt32 index, const DataType &item)
 Retrieve the item at a given position from the field. More...
 
SInt32 GetCount () const
 Get the number of items in the field. More...
 
Bool IsEqual (const Field &other) const
 Compare the field to another one. More...
 
bool operator== (const Field &rhs) const
 The "equal to" comparison operator, calls IsEqual(). More...
 
bool operator!= (const Field &rhs) const
 The "not equal to" comparison operator, calls IsEqual(). More...
 
Bool IsIndexValid (SInt32 index) const
 Check if a given index is a valid index. More...
 
DataType & operator[] (SInt32 index)
 Retrieve the item at a given position from the field. More...
 
const DataType & operator[] (SInt32 index) const
 Retrieve the item at a given position from the field. More...
 
DataType & Get (SInt32 index)
 Get the item at a given position from the field. More...
 
const DataType & Get (SInt32 index) const
 Get the item at a given position from the field. More...
 
 operator DataType * ()
 Conversion operator to the underlying raw array. More...
 
 operator const DataType * () const
 Conversion operator to the underlying raw array. More...
 
UInt32 GetByteSize () const
 Get the number of bytes of the underlying raw array. More...
 
ConstIterator Begin () const
 Get the const iterator to the first item. More...
 
ConstIterator End () const
 Get the const iterator next to the last item. More...
 
ConstIterator GetIter (SInt32 index) const
 Get the const iterator of a specified index. More...
 
SInt32 GetIterIndex (ConstIterator iterator) const
 Get the item index by iterator. More...
 
void Swap (Field &other)
 Exchange the content of the field with a given second one. More...
 
Iterator Begin ()
 Get the iterator to the first item. More...
 
Iterator End ()
 Get the iterator next to the last item. More...
 
Iterator GetIter (SInt32 index)
 Get the iterator of a specified index. More...
 

Detailed Description

template<class DataType, UInt32 COUNT>
class Murl::Field< DataType, COUNT >

A generic field template class for fixed-size arrays.

Template Parameters
DataTypeThe value's data type of the field.

Constructor & Destructor Documentation

◆ Field()

template<class DataType , UInt32 COUNT>
Murl::Field< DataType, COUNT >::Field ( const Field< DataType, COUNT > &  other)
inline

Construct a field from an already existing one, performing a deep copy.

Parameters
otherThe field to copy.

Member Function Documentation

◆ operator=()

template<class DataType , UInt32 COUNT>
void Murl::Field< DataType, COUNT >::operator= ( const Field< DataType, COUNT > &  other)
inline

Assign the content of another field to this one, performing a deep copy.

Parameters
otherThe source field.

◆ Set() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::Set ( SInt32  index,
const DataType &  item 
)
inline

Initialize an item with a given item.

Parameters
indexThe index of the item to set.
itemThe source item to copy.
Returns
A reference to the set item.

Referenced by Murl::Field< DataType, COUNT >::Fill().

◆ Set() [2/2]

template<class DataType , UInt32 COUNT>
Bool Murl::Field< DataType, COUNT >::Set ( SInt32  index,
const DataType &  item,
SInt32  count 
)
inline

Initialize a range of items with a given item.

Parameters
indexThe index of the first item to set.
itemThe source item to copy.
countThe number of items to set.
Returns
true if successful.

◆ Fill()

template<class DataType , UInt32 COUNT>
void Murl::Field< DataType, COUNT >::Fill ( const DataType &  item)
inline

Fill all items with a given item.

Parameters
itemThe source item to copy.

References Murl::Field< DataType, COUNT >::Set().

◆ Swap() [1/2]

template<class DataType , UInt32 COUNT>
void Murl::Field< DataType, COUNT >::Swap ( SInt32  index1,
SInt32  index2 
)
inline

Swap two field items.

Parameters
index1The index of the first item.
index2The index of the second item.

References Murl::Util::Swap().

◆ Find() [1/2]

template<class DataType , UInt32 COUNT>
SInt32 Murl::Field< DataType, COUNT >::Find ( const DataType &  item) const
inline

Find the first occurrence of a given item in the field.

Parameters
itemThe item to find.
Returns
The index of the item, or -1 if the item was not found.

◆ Find() [2/2]

template<class DataType , UInt32 COUNT>
SInt32 Murl::Field< DataType, COUNT >::Find ( const DataType &  item,
SInt32  firstIndex 
) const
inline

Find the first occurrence of a given item in the field.

Parameters
itemThe item to find.
firstIndexThe index where to start searching.
Returns
The index of the item, or -1 if the item was not found.

◆ FindLast() [1/2]

template<class DataType , UInt32 COUNT>
SInt32 Murl::Field< DataType, COUNT >::FindLast ( const DataType &  item) const
inline

Find the last occurrence of a given item in the field.

Parameters
itemThe item to find.
Returns
The index of the item, or -1 if the item was not found.

◆ FindLast() [2/2]

template<class DataType , UInt32 COUNT>
SInt32 Murl::Field< DataType, COUNT >::FindLast ( const DataType &  item,
SInt32  lastIndex 
) const
inline

Find the last occurrence of a given item in the field.

Parameters
itemThe item to find.
lastIndexThe index where to start searching.
Returns
The index of the item, or -1 if the item was not found.

◆ Front() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::Front ( )
inline

Retrieve the first item from the field.

Synonymous to Bottom().

Returns
A reference to the first item.

References Murl::Field< DataType, COUNT >::Bottom().

◆ Front() [2/2]

template<class DataType , UInt32 COUNT>
const DataType& Murl::Field< DataType, COUNT >::Front ( ) const
inline

Retrieve the first item from the field.

Synonymous to Bottom().

Returns
A const reference to the first item.

References Murl::Field< DataType, COUNT >::Bottom().

◆ Back() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::Back ( )
inline

Retrieve the last item from the field.

Synonymous to Top().

Returns
A reference to the last item.

References Murl::Field< DataType, COUNT >::Top().

◆ Back() [2/2]

template<class DataType , UInt32 COUNT>
const DataType& Murl::Field< DataType, COUNT >::Back ( ) const
inline

Retrieve the last item from the field.

Synonymous to Top().

Returns
A const reference to the last item.

References Murl::Field< DataType, COUNT >::Top().

◆ Bottom() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::Bottom ( )
inline

Retrieve the first item from the field.

Returns
A reference to the first item.

Referenced by Murl::Field< DataType, COUNT >::Front().

◆ Bottom() [2/2]

template<class DataType , UInt32 COUNT>
const DataType& Murl::Field< DataType, COUNT >::Bottom ( ) const
inline

Retrieve the first item from the field.

Returns
A const reference to the first item.

◆ Top() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::Top ( )
inline

Retrieve the last item from the field.

Returns
A reference to the last item.

Referenced by Murl::Field< DataType, COUNT >::Back().

◆ Top() [2/2]

template<class DataType , UInt32 COUNT>
const DataType& Murl::Field< DataType, COUNT >::Top ( ) const
inline

Retrieve the last item from the field.

Returns
A const reference to the last item.

◆ At() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::At ( SInt32  index)
inline

Retrieve the item at a given position from the field.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A reference to the specified item.

◆ At() [2/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::At ( SInt32  index,
const DataType &  item 
)
inline

Retrieve the item at a given position from the field.

Parameters
indexThe zero-based index of the item to retrieve.
itemThe reference item used for initialization.
Returns
A reference to the specified item.

◆ GetCount()

template<class DataType , UInt32 COUNT>
SInt32 Murl::Field< DataType, COUNT >::GetCount ( ) const
inline

Get the number of items in the field.

Returns
The number of items.

◆ IsEqual()

template<class DataType , UInt32 COUNT>
Bool Murl::Field< DataType, COUNT >::IsEqual ( const Field< DataType, COUNT > &  other) const
inline

Compare the field to another one.

Parameters
otherThe field to compare.
Returns
true if both fields have identical contents.

Referenced by Murl::Field< DataType, COUNT >::operator!=(), and Murl::Field< DataType, COUNT >::operator==().

◆ operator==()

template<class DataType , UInt32 COUNT>
bool Murl::Field< DataType, COUNT >::operator== ( const Field< DataType, COUNT > &  rhs) const
inline

The "equal to" comparison operator, calls IsEqual().

Parameters
rhsThe right hand side field to compare.
Returns
true if both fields have identical contents.

References Murl::Field< DataType, COUNT >::IsEqual().

◆ operator!=()

template<class DataType , UInt32 COUNT>
bool Murl::Field< DataType, COUNT >::operator!= ( const Field< DataType, COUNT > &  rhs) const
inline

The "not equal to" comparison operator, calls IsEqual().

Parameters
rhsThe right hand side field to compare.
Returns
true if both fields do not have identical contents.

References Murl::Field< DataType, COUNT >::IsEqual().

◆ IsIndexValid()

template<class DataType , UInt32 COUNT>
Bool Murl::Field< DataType, COUNT >::IsIndexValid ( SInt32  index) const
inline

Check if a given index is a valid index.

Parameters
indexThe index to check.
Returns
true if index >= 0 and index < GetCount().

◆ operator[]() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::operator[] ( SInt32  index)
inline

Retrieve the item at a given position from the field.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A reference to the specified item.

◆ operator[]() [2/2]

template<class DataType , UInt32 COUNT>
const DataType& Murl::Field< DataType, COUNT >::operator[] ( SInt32  index) const
inline

Retrieve the item at a given position from the field.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A const reference to the specified item.

◆ Get() [1/2]

template<class DataType , UInt32 COUNT>
DataType& Murl::Field< DataType, COUNT >::Get ( SInt32  index)
inline

Get the item at a given position from the field.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A reference to the specified item.

◆ Get() [2/2]

template<class DataType , UInt32 COUNT>
const DataType& Murl::Field< DataType, COUNT >::Get ( SInt32  index) const
inline

Get the item at a given position from the field.

Parameters
indexThe zero-based index of the item to retrieve.
Returns
A const reference to the specified item.

◆ operator DataType *()

template<class DataType , UInt32 COUNT>
Murl::Field< DataType, COUNT >::operator DataType * ( )
inline

Conversion operator to the underlying raw array.

Returns
A pointer to the raw array.

◆ operator const DataType *()

template<class DataType , UInt32 COUNT>
Murl::Field< DataType, COUNT >::operator const DataType * ( ) const
inline

Conversion operator to the underlying raw array.

Returns
A pointer to the constant raw array.

◆ GetByteSize()

template<class DataType , UInt32 COUNT>
UInt32 Murl::Field< DataType, COUNT >::GetByteSize ( ) const
inline

Get the number of bytes of the underlying raw array.

Returns
The number of bytes of the underlying raw array.

◆ Begin() [1/2]

template<class DataType , UInt32 COUNT>
ConstIterator Murl::Field< DataType, COUNT >::Begin ( ) const
inline

Get the const iterator to the first item.

Returns
The const iterator to the first item.

Referenced by Murl::Field< DataType, COUNT >::GetIterIndex().

◆ End() [1/2]

template<class DataType , UInt32 COUNT>
ConstIterator Murl::Field< DataType, COUNT >::End ( ) const
inline

Get the const iterator next to the last item.

Returns
The const iterator next to the last item.

Referenced by Murl::Field< DataType, COUNT >::GetIterIndex().

◆ GetIter() [1/2]

template<class DataType , UInt32 COUNT>
ConstIterator Murl::Field< DataType, COUNT >::GetIter ( SInt32  index) const
inline

Get the const iterator of a specified index.

Parameters
indexThe index for the iterator.
Returns
The const iterator or null if the index is out of range.

◆ GetIterIndex()

template<class DataType , UInt32 COUNT>
SInt32 Murl::Field< DataType, COUNT >::GetIterIndex ( ConstIterator  iterator) const
inline

Get the item index by iterator.

(!) Adding or removing items will invalidate iterators.

Parameters
iteratorThe iterator of the item.
Returns
The index of the item, or -1 if the iterator is invalid.

References Murl::Field< DataType, COUNT >::Begin(), and Murl::Field< DataType, COUNT >::End().

◆ Swap() [2/2]

template<class DataType , UInt32 COUNT>
void Murl::Field< DataType, COUNT >::Swap ( Field< DataType, COUNT > &  other)
inline

Exchange the content of the field with a given second one.

Parameters
otherThe second field.

References Murl::Util::Swap().

◆ Begin() [2/2]

template<class DataType , UInt32 COUNT>
Iterator Murl::Field< DataType, COUNT >::Begin ( )
inline

Get the iterator to the first item.

Returns
The iterator to the first item.

◆ End() [2/2]

template<class DataType , UInt32 COUNT>
Iterator Murl::Field< DataType, COUNT >::End ( )
inline

Get the iterator next to the last item.

Returns
The iterator next to the last item.

◆ GetIter() [2/2]

template<class DataType , UInt32 COUNT>
Iterator Murl::Field< DataType, COUNT >::GetIter ( SInt32  index)
inline

Get the iterator of a specified index.

Parameters
indexThe index for the iterator.
Returns
The iterator or null if the index is out of range.

The documentation for this class was generated from the following file:
  • murl_field.h


Copyright © 2011-2024 Spraylight GmbH.