Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY > Class Template Reference

#include <cArraySort.h>

Inheritance diagram for Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >:
Gray::cArrayTyped< TYPE, TYPE_ARG > Gray::CArray< TYPE, ARG_TYPE > Gray::CObject Gray::cArraySortFacade< TYPE, TYPE_PTR, TYPE_KEY > Gray::cArraySortFacade< cRefPtr< TYPE >, TYPE *, TYPE_KEY > Gray::cArraySortFacade< TYPE *, TYPE *, const GChar_t * > Gray::cArraySortFacade< TYPE, TYPE_PTR, HASHCODE_t > Gray::cArraySortString< TYPE > Gray::cArraySortString< FILECHAR_t > Gray::cArraySortStructHash< GrayLib::cTextLocEntry > Gray::cArraySortStructHash< cIniKeyValue > Gray::cArraySortStructHash< TYPE_INST, THREADID_t > Gray::cArraySortStructHash< GrayLib::cMailTag > Gray::cArraySortStructHash< GrayLib::cHttpHeadTag > Gray::cArraySortStructHash< CMapKey, HASHCODE_t > Gray::cArraySortStructHash< cAtomRef, ATOMCODE_t > Gray::cArraySortVal< UID_t > Gray::cArraySortVal< UIDINDEX_t > Gray::cArraySortVal< SCRIPTINTERFACEID_t > Gray::cArraySortVal< Gray::cPtrTrace * > Gray::cPairSortBase< cPair< _TYPE_A, _TYPE_B >, const ATOMCHAR_t * > Gray::cPairSortBase< cPair< _TYPE_A, _TYPE_B >, _TYPE_A >

Public Types

typedef cArrayTyped< TYPE, TYPE_ARG > SUPER_t
 
typedef TYPE_KEY KEY_t
 
typedef SUPER_t::REF_t REF_t
 
- Public Types inherited from Gray::cArrayTyped< TYPE, TYPE_ARG >
typedef CArray< TYPE, TYPE_ARG > SUPER_t
 
typedef cArrayTyped< TYPE, TYPE_ARG > THIS_t
 
typedef ITERATE_t iterator
 
typedef ITERATE_t const_iterator
 
typedef TYPE ELEM_t
 What type is stored. More...
 
typedef TYPE_ARG REF_t
 How to refer to this? value or ref or pointer? More...
 

Public Member Functions

virtual ~cArraySorted ()
 
ITERATE_t FindINear (REF_t pNew, COMPARE_t &iCompareRes) const
 
ITERATE_t FindINearKey (KEY_t key, COMPARE_t &iCompareRes) const
 
ITERATE_t FindIForKey (KEY_t key) const
 
ITERATE_t FindIFirstForKey (TYPE_KEY nKey) const
 
ITERATE_t FindILastForKey (TYPE_KEY nKey) const
 
ITERATE_t AddPresorted (ITERATE_t index, COMPARE_t iCompareRes, TYPE_ARG pNew)
 
bool RemoveKey (TYPE_KEY key)
 
ITERATE_t Add (TYPE_ARG pNew)
 
void AddArray (const SUPER_t &a)
 
- Public Member Functions inherited from Gray::cArrayTyped< TYPE, TYPE_ARG >
void QSort ()
 
 cArrayTyped () noexcept
 
 cArrayTyped (const THIS_t &rArray)
 
 cArrayTyped (ITERATE_t iSize)
 
virtual ~cArrayTyped ()
 
bool isValidCheck () const noexcept
 < memory allocation and structure definitions are valid. More...
 
bool IsValidIndex (ITERATE_t i) const noexcept
 
ITERATE_t ClampValidIndex (ITERATE_t i) const noexcept
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const noexcept
 
void AssertValidIndex (ITERATE_t nIndex) const
 
const TYPEGetAtSecure (ITERATE_t nIndex) const
 
TYPEElementAtSecure (ITERATE_t nIndex)
 
REF_t ConstElementAt (ITERATE_t nIndex) const
 
TYPEoperator[] (ITERATE_t nIndex)
 
const TYPEoperator[] (ITERATE_t nIndex) const
 
TYPEHead ()
 
TYPETail ()
 
TYPEElementAtHead ()
 
TYPEElementAtTail ()
 
REF_t ConstHead () const
 
REF_t ConstTail () const
 
REF_t GetAtTail ()
 
void UnLinkIndex (ITERATE_t nIndex)
 
void Swap (ITERATE_t i, ITERATE_t j)
 
void SetCopy (const cArrayTyped< TYPE, TYPE_ARG > &aValues)
 
const cArrayTyped< TYPE, TYPE_ARG > & operator= (const cArrayTyped< TYPE, TYPE_ARG > &aValues)
 
ITERATE_t FindIFor (TYPE_ARG arg) const
 
bool HasArg (TYPE_ARG arg) const
 
void RemoveLast ()
 
ELEM_t PopHead ()
 
ELEM_t PopTail ()
 
bool RemoveArg (TYPE_ARG arg)
 
void UnLinkArg (TYPE_ARG arg)
 
ITERATE_t AddTail (TYPE_ARG newElement)
 
ITERATE_t PushTail (TYPE_ARG newElement)
 
void AddHead (TYPE_ARG newElement)
 
TYPEget_DataWork () const
 
void AddArray (const SUPER_t &src)
 
bool IsEqualArray (const SUPER_t &aValues) const
 
bool isArraySorted () const
 
bool isArraySortedND () const
 
- Public Member Functions inherited from Gray::CArray< TYPE, ARG_TYPE >
 CArray () noexcept
 
 CArray (THIS_t &&ref) noexcept
 
virtual ~CArray ()
 
bool IsValidMallocSize () const noexcept
 
ITERATE_t GetSize () const noexcept
 
ITERATE_t GetUpperBound () const noexcept
 
bool IsEmpty () const noexcept
 
void SetSize (ITERATE_t nNewSize)
 
ITERATE_t GetMallocSize () const noexcept
 
void RemoveAll ()
 Clean up. More...
 
const TYPEGetAt (ITERATE_t nIndex) const
 
TYPEElementAt (ITERATE_t nIndex)
 
void SetAt (ITERATE_t nIndex, ARG_TYPE newElement)
 
const TYPEGetData () const
 
TYPEGetData ()
 
void SetDataArrayPtr (TYPE *pData, ITERATE_t nSize)
 
void SetAtGrow (ITERATE_t nIndex, ARG_TYPE newElement)
 
ITERATE_t Add (ARG_TYPE newElement)
 
void Copy (const CArray &src)
 
TYPEoperator[] (ITERATE_t nIndex)
 
const TYPEoperator[] (ITERATE_t nIndex) const
 
void InsertAt (ITERATE_t nIndex, ARG_TYPE newElement)
 
void RemoveAt (ITERATE_t nIndex)
 
void RemoveAt (ITERATE_t nIndex, ITERATE_t iQty)
 
void MoveElement (ITERATE_t iFrom, ITERATE_t iTo)
 
- Public Member Functions inherited from Gray::CObject
virtual ~CObject ()
 
virtual void AssertValid () const
 < memory allocation and structure definitions are valid. More...
 
virtual void Serialize (cArchive &a)
 

Protected Member Functions

virtual COMPARE_t CompareKey (KEY_t key1, REF_t Data2) const
 
bool RemoveArgKey (REF_t pObj, KEY_t key)
 
- Protected Member Functions inherited from Gray::cArrayTyped< TYPE, TYPE_ARG >
virtual COMPARE_t CompareData (REF_t Data1, REF_t Data2) const noexcept
 
ITERATE_t QSortPartition (ITERATE_t iLeft, ITERATE_t iRight)
 
void QSort (ITERATE_t iLeft, ITERATE_t iRight)
 
- Protected Member Functions inherited from Gray::CArray< TYPE, ARG_TYPE >
bool IsValidIndex (ITERATE_t i) const noexcept
 

Additional Inherited Members

- Protected Attributes inherited from Gray::CArray< TYPE, ARG_TYPE >
TYPEm_pData
 the actual array of data More...
 
ITERATE_t m_nSize
 Number of elements (upperBound - 1) More...
 

Detailed Description

template<class TYPE, class TYPE_ARG, typename TYPE_KEY>
class Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >

An array of some sorted TYPE. duplicates are destroyed. default is that it is just sorted by its bytes. Similar to .NET HashSet

Member Typedef Documentation

◆ KEY_t

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
typedef TYPE_KEY Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::KEY_t

◆ REF_t

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
typedef SUPER_t::REF_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::REF_t

◆ SUPER_t

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
typedef cArrayTyped<TYPE, TYPE_ARG> Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::SUPER_t

Constructor & Destructor Documentation

◆ ~cArraySorted()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
virtual Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::~cArraySorted ( )
inlinevirtual

Member Function Documentation

◆ Add()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::Add ( TYPE_ARG  pNew)

Insertion sort. duplicates are destroyed.

Returns
index in the array. (temporary if sorted)

◆ AddArray()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
void Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::AddArray ( const SUPER_t a)
inline

Add all the entries in array a to this array. sorted add.

◆ AddPresorted()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::AddPresorted ( ITERATE_t  index,
COMPARE_t  iCompareRes,
TYPE_ARG  pNew 
)
inline
Returns
index in the array. (temporary if sorted)

◆ CompareKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
virtual COMPARE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::CompareKey ( KEY_t  key1,
REF_t  Data2 
) const
inlineprotectedvirtual

Compare by a key that may not be part of a data record (yet). Default implementation. Overload this for proper implementation.

Note
If we reach here assume the key is &reference to the whole record !

Reimplemented in Gray::cPairSortBase< _TYPE_PAIR, _TYPE_KEY >.

◆ FindIFirstForKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::FindIFirstForKey ( TYPE_KEY  nKey) const
inline

Find first the occurrence of this nKey. Since values are allowed to duplicate.

Returns
index, -1 = k_ITERATE_BAD = none.

◆ FindIForKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::FindIForKey ( KEY_t  key) const
inline

Find index for exact key match. Similar to FindIFor()

Returns
index into array. 0 based of course. -1 = failed

◆ FindILastForKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::FindILastForKey ( TYPE_KEY  nKey) const
inline

Find last the occurrence of this nKey. Since values are allowed to duplicate.

Returns
index, -1 = k_ITERATE_BAD = none.

◆ FindINear()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::FindINear ( REF_t  pNew,
COMPARE_t iCompareRes 
) const

Do a binary search for the elements key.

Returns
index riCompareRes = COMPARE_t 0 = match with index. we may allow duplicates? -1 = key is less than index. COMPARE_Less +1 = key is greater than index

◆ FindINearKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
ITERATE_t Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::FindINearKey ( KEY_t  key,
COMPARE_t iCompareRes 
) const

Do a binary search for the key.

Returns
  • index
  • iCompareRes = 0 = key match with element at the index. -1 = key is less than element at the index. COMPARE_Less +1 = key is greater than element at the index

◆ RemoveArgKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
bool Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::RemoveArgKey ( REF_t  pObj,
KEY_t  key 
)
inlineprotected

Can't use this for arrays that allow dupes ! (e.g. get_Value()) Use FindIForAK() instead.

◆ RemoveKey()

template<class TYPE , class TYPE_ARG , typename TYPE_KEY >
bool Gray::cArraySorted< TYPE, TYPE_ARG, TYPE_KEY >::RemoveKey ( TYPE_KEY  key)
inline

Might be dangerous for arrays that allow dupes?


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