JX Application Framework
Loading...
Searching...
No Matches
Public Member Functions | List of all members
JPtrArray< T > Class Template Reference

#include <JPtrArray.h>

Inheritance diagram for JPtrArray< T >:
[legend]

Public Member Functions

 JPtrArray (const JPtrArrayT::CleanUpAction action, const JSize aBlockSize=10)
 
 JPtrArray (const JPtrArray< T > &source, const JPtrArrayT::CleanUpAction action)
 
 JPtrArray (JPtrArray< T > &&dyingSource) noexcept
 
 ~JPtrArray () override
 
const JPtrArray< T > & CopyPointers (const JPtrArray< T > &source, const JPtrArrayT::CleanUpAction action, const bool append)
 
void InsertAtIndex (const JIndex index, T *dataPtr)
 
void Prepend (T *dataPtr)
 
void Append (T *dataPtr)
 
void InsertBefore (const T *beforePtr, T *dataPtr)
 
void InsertAfter (const T *afterPtr, T *dataPtr)
 
void SetItem (const JIndex index, T *dataPtr, const JPtrArrayT::SetAction action)
 
void SetToNull (const JIndex index, const JPtrArrayT::SetAction action)
 
const JPtrArray< T > & CopyObjects (const JPtrArray< T > &source, const JPtrArrayT::CleanUpAction action, const bool append)
 
void InsertAtIndex (const JIndex index, const T &data)
 
void Prepend (const T &data)
 
void Append (const T &data)
 
void InsertBefore (const T *beforePtr, const T &data)
 
void InsertAfter (const T *afterPtr, const T &data)
 
void SetItem (const JIndex index, const T &data, const JPtrArrayT::SetAction action)
 
bool Remove (const T *dataPtr)
 
void DeleteItem (const JIndex index)
 
void DeleteAll ()
 
void DeleteItemAsArray (const JIndex index)
 
void DeleteAllAsArrays ()
 
bool Includes (const T *dataPtr) const
 
bool Find (const T *dataPtr, JIndex *itemIndex) const
 
JPtrArrayT::CleanUpAction GetCleanUpAction () const
 
void SetCleanUpAction (const JPtrArrayT::CleanUpAction action)
 
void CleanOut ()
 
- Public Member Functions inherited from JArray< T * >
 JArray (const JSize blockSize=10)
 
 JArray (const JArray< T * > &source)
 
 JArray (JArray< T * > &&dyingSource) noexcept
 
 ~JArray () override
 
JArray< T * > & operator= (const JArray< T * > &source)
 
 operator const T * * () const
 
const T * * GetCArray () const
 
T * * AllocateCArray () const
 
T * GetItem (const JIndex index) const
 
void SetItem (const JIndex index, const T * &data)
 
T * GetItemFromEnd (const JIndex index) const
 
void SetItemFromEnd (const JIndex index, const T * &data)
 
T * GetFirstItem () const override
 
T * GetLastItem () const override
 
void InsertItemAtIndex (const JIndex index, const T * &data)
 
void PrependItem (const T * &data) override
 
void AppendItem (const T * &data) override
 
void RemoveItem (const JIndex index)
 
void RemoveNextItems (const JIndex firstIndex, const JSize count)
 
void RemovePrevItems (const JIndex lastIndex, const JSize count)
 
void RemoveItems (const JIndexRange &range)
 
void RemoveItems (const JListT::ItemsRemoved &info)
 
void RemoveAll () override
 
void MoveItemToIndex (const JIndex currentIndex, const JIndex newIndex)
 
void MoveItemToIndex (const JListT::ItemMoved &info)
 
void SwapItems (const JIndex index1, const JIndex index2)
 
void SwapItems (const JListT::ItemsSwapped &info)
 
JListIterator< T * > * NewIterator (const JListT::Position start=JListT::kStartAtBeginning, const JIndex index=0) override
 
JListIterator< T * > * NewIterator (const JListT::Position start=JListT::kStartAtBeginning, const JIndex index=0) const override
 
JSize GetBlockSize () const
 
void SetBlockSize (const JSize newBlockSize)
 
void Sort ()
 
bool InsertSorted (const T * &data, const bool insertIfDuplicate=true, JIndex *index=nullptr)
 
JIndex GetInsertionSortIndex (const T * &data, bool *isDuplicate=nullptr) const
 
bool SearchSorted (const T * &target, const JListT::SearchReturn which, JIndex *index) const
 
JIndex SearchSortedOTI (const T * &target, const JListT::SearchReturn which, bool *found) const
 
void QuickSort (int(*compare)(const void *, const void *))
 
const T * * begin () const
 
const T * * end () const
 
- Public Member Functions inherited from JList< T >
 JList ()
 
 JList (const JList< T > &source)
 
 ~JList () override
 
void SetCompareFunction (const std::function< std::weak_ordering(const T &, const T &)> compareFn)
 
void CopyCompareFunction (const JList< T > &source)
 
void ClearCompareFunction ()
 
JListT::SortOrder GetSortOrder () const
 
void SetSortOrder (const JListT::SortOrder order)
 
bool IsSorted () const
 
- Public Member Functions inherited from JCollection
 JCollection ()
 
 JCollection (const JCollection &source)
 
 ~JCollection () override
 
JCollectionoperator= (const JCollection &source)
 
JSize GetItemCount () const
 
bool IsEmpty () const
 
bool IndexValid (const JIndex index) const
 
JIndex GetIndexFromEnd (const JIndex index) const
 
JString ToString () const override
 
- Public Member Functions inherited from JBroadcaster
 JBroadcaster ()
 
virtual ~JBroadcaster ()
 
JBroadcasteroperator= (const JBroadcaster &source)
 
bool HasSenders () const
 
JSize GetSenderCount () const
 
bool HasRecipients () const
 
JSize GetRecipientCount () const
 
template<class T >
void ListenTo (const JBroadcaster *sender, const std::function< void(const T &)> &f)
 

Additional Inherited Members

- Protected Member Functions inherited from JArray< T * >
const T * & ProtectedGetItem (const JIndex index) const
 
- Protected Member Functions inherited from JList< T >
std::function< std::weak_ordering(const T &, const T &)> * GetCompareFunction () const
 
void ListAssigned (const JList< T > &source)
 
void NotifyIterators (const JBroadcaster::Message &message)
 
- Protected Member Functions inherited from JCollection
void ItemAdded ()
 
void ItemRemoved ()
 
void SetItemCount (const JSize newItemCount)
 
- Protected Member Functions inherited from JBroadcaster
 JBroadcaster (const JBroadcaster &source)
 
void ListenTo (const JBroadcaster *sender)
 
void StopListening (const JBroadcaster *sender)
 
void ClearWhenGoingAway (const JBroadcaster *sender, void *pointerToMember)
 
void StopListening (const JBroadcaster *sender, const std::type_info &messageType)
 
template<class T >
void Send (JBroadcaster *recipient, const T &message)
 
template<class T >
void Broadcast (const T &message)
 
virtual void Receive (JBroadcaster *sender, const Message &message)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 
virtual void ReceiveWithFeedback (JBroadcaster *sender, Message *message)
 
virtual void ReceiveGoingAway (JBroadcaster *sender)
 

Detailed Description

template<class T>
class JPtrArray< T >

Interface for JPtrArray class

Comparison functions for JString, for use with JPtrArray<JString>.

Constructor & Destructor Documentation

◆ JPtrArray() [1/3]

template<class T >
JPtrArray< T >::JPtrArray ( const JPtrArrayT::CleanUpAction  action,
const JSize  blockSize = 10 
)
                The Pointer Array Template Class

Template for a dynamically sized array of pointers. The pointers are stored contiguously.

Since only the pointers are stored, this is good for objects.

Implementation notes:

Retrieving an item from the actual array gives a pointer.

We do not override ToString(): Since this function is virtual, it is always instantiated. Thus, we cannot print the objects, because they might not have ToString() or operator<<

◆ JPtrArray() [2/3]

template<class T >
JPtrArray< T >::JPtrArray ( const JPtrArray< T > &  source,
const JPtrArrayT::CleanUpAction  action 
)

CleanUpAction must not be kDeleteAll* for both original and copy.

◆ JPtrArray() [3/3]

template<class T >
JPtrArray< T >::JPtrArray ( JPtrArray< T > &&  dyingSource)
noexcept

◆ ~JPtrArray()

template<class T >
JPtrArray< T >::~JPtrArray ( )
override

Member Function Documentation

◆ Append() [1/2]

template<class T >
void JPtrArray< T >::Append ( const T &  data)

◆ Append() [2/2]

template<class T >
void JPtrArray< T >::Append ( T *  dataPtr)

◆ CleanOut()

template<class T >
void JPtrArray< T >::CleanOut ( )

◆ CopyObjects()

template<class T >
const JPtrArray< T > & JPtrArray< T >::CopyObjects ( const JPtrArray< T > &  source,
const JPtrArrayT::CleanUpAction  action,
const bool  append 
)

CleanUpAction can be kDeleteAll* for both original and copy.

If !append, CleanOut() is called first.

◆ CopyPointers()

template<class T >
const JPtrArray< T > & JPtrArray< T >::CopyPointers ( const JPtrArray< T > &  source,
const JPtrArrayT::CleanUpAction  action,
const bool  append 
)

CleanUpAction should not be kDeleteAll* for both original and copy.

If !append, CleanOut() is called first.

◆ DeleteAll()

template<class T >
void JPtrArray< T >::DeleteAll ( )

◆ DeleteAllAsArrays()

template<class T >
void JPtrArray< T >::DeleteAllAsArrays ( )

◆ DeleteItem()

template<class T >
void JPtrArray< T >::DeleteItem ( const JIndex  index)

◆ DeleteItemAsArray()

template<class T >
void JPtrArray< T >::DeleteItemAsArray ( const JIndex  index)

◆ Find()

template<class T >
bool JPtrArray< T >::Find ( const T *  dataPtr,
JIndex itemIndex 
) const

JIndex is 1 based. Returns FALSE if item is not in array.

◆ GetCleanUpAction()

template<class T >
JPtrArrayT::CleanUpAction JPtrArray< T >::GetCleanUpAction ( ) const

What to do when the destructor is called. This is especially useful for objects allocated on the stack, because one can set the appropriate action and then never have to worry about short-circuit returns.

◆ Includes()

template<class T >
bool JPtrArray< T >::Includes ( const T *  dataPtr) const

Returns TRUE if the JPtrArray contains the specified item.

◆ InsertAfter() [1/2]

template<class T >
void JPtrArray< T >::InsertAfter ( const T *  afterPtr,
const T &  data 
)

◆ InsertAfter() [2/2]

template<class T >
void JPtrArray< T >::InsertAfter ( const T *  afterPtr,
T *  dataPtr 
)

If afterPtr isn't in the array, dataPtr is appended.

◆ InsertAtIndex() [1/2]

template<class T >
void JPtrArray< T >::InsertAtIndex ( const JIndex  index,
const T &  data 
)

◆ InsertAtIndex() [2/2]

template<class T >
void JPtrArray< T >::InsertAtIndex ( const JIndex  index,
T *  dataPtr 
)

◆ InsertBefore() [1/2]

template<class T >
void JPtrArray< T >::InsertBefore ( const T *  beforePtr,
const T &  data 
)

◆ InsertBefore() [2/2]

template<class T >
void JPtrArray< T >::InsertBefore ( const T *  beforePtr,
T *  dataPtr 
)

If beforePtr isn't in the array, dataPtr is prepended.

◆ Prepend() [1/2]

template<class T >
void JPtrArray< T >::Prepend ( const T &  data)

◆ Prepend() [2/2]

template<class T >
void JPtrArray< T >::Prepend ( T *  dataPtr)

◆ Remove()

template<class T >
bool JPtrArray< T >::Remove ( const T *  dataPtr)

◆ SetCleanUpAction()

template<class T >
void JPtrArray< T >::SetCleanUpAction ( const JPtrArrayT::CleanUpAction  action)

◆ SetItem() [1/2]

template<class T >
void JPtrArray< T >::SetItem ( const JIndex  index,
const T &  data,
const JPtrArrayT::SetAction  action 
)

◆ SetItem() [2/2]

template<class T >
void JPtrArray< T >::SetItem ( const JIndex  index,
T *  dataPtr,
const JPtrArrayT::SetAction  action 
)

This function avoids the static_cast required for SetItem().

◆ SetToNull()

template<class T >
void JPtrArray< T >::SetToNull ( const JIndex  index,
const JPtrArrayT::SetAction  action 
)

This function avoids the static_cast required for SetItem().


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