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

#include <JAliasArray.h>

Inheritance diagram for JAliasArray< T >:
[legend]

Public Member Functions

 JAliasArray (JArray< T > *data, const std::function< std::weak_ordering(const T &, const T &)> compareFn, const JListT::SortOrder order)
 
 ~JAliasArray () override
 
JArray< T > * GetData ()
 
const JArray< T > & GetData () const
 
JIndex GetItemIndex (const JIndex index) const
 
JIndex GetItemIndexFromEnd (const JIndex index) const
 
const T GetItem (const JIndex index) const
 
void SetItem (const JIndex index, const T &data)
 
const T GetFirstItem () const
 
const T GetLastItem () const
 
const T GetItemFromEnd (const JIndex index) const
 
void SetItemFromEnd (const JIndex index, const T &data)
 
void SetCompareFunction (const std::function< std::weak_ordering(const T &, const T &)> compareFn)
 
JListT::SortOrder GetSortOrder () const
 
void SetSortOrder (const JListT::SortOrder order)
 
bool SearchSorted (const T &target, const JListT::SearchReturn which, JIndex *index) const
 
JIndex SearchSortedOTI (const T &target, const JListT::SearchReturn which, bool *found) 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)
 

Protected Member Functions

void Receive (JBroadcaster *sender, const Message &message) override
 
void ReceiveGoingAway (JBroadcaster *sender) override
 
- 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)
 
void SendWithFeedback (JBroadcaster *recipient, Message *message)
 
void BroadcastWithFeedback (Message *message)
 
virtual void ReceiveWithFeedback (JBroadcaster *sender, Message *message)
 

Constructor & Destructor Documentation

◆ JAliasArray()

template<class T >
JAliasArray< T >::JAliasArray ( JArray< T > *  data,
const std::function< std::weak_ordering(const T &, const T &)>  compareFn,
const JListT::SortOrder  order 
)

Template for an array of indices into a JArray. The indices are sorted by applying a comparison function to the data in the JArray. This allows you to sort a list in more than one way without having to duplicate the data itself.

We are obviously dead in the water if itsData is deleted. Rather than making a mess of the interface and returning bool everywhere, we instead require that the JAliasArray be tossed when the data goes away. By blowing up in any member function instead of blowing up in ReceiveGoingAway(), we allow the data to be deleted before the JAliasArray.

◆ ~JAliasArray()

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

Member Function Documentation

◆ GetData() [1/2]

template<class T >
JArray< T > * JAliasArray< T >::GetData ( )

◆ GetData() [2/2]

template<class T >
const JArray< T > & JAliasArray< T >::GetData ( ) const

◆ GetFirstItem()

template<class T >
const T JAliasArray< T >::GetFirstItem ( ) const

◆ GetItem()

template<class T >
const T JAliasArray< T >::GetItem ( const JIndex  index) const

Returns the actual data.

◆ GetItemFromEnd()

template<class T >
const T JAliasArray< T >::GetItemFromEnd ( const JIndex  index) const

◆ GetItemIndex()

template<class T >
JIndex JAliasArray< T >::GetItemIndex ( const JIndex  index) const

Returns the index into the data.

◆ GetItemIndexFromEnd()

template<class T >
JIndex JAliasArray< T >::GetItemIndexFromEnd ( const JIndex  index) const

◆ GetLastItem()

template<class T >
const T JAliasArray< T >::GetLastItem ( ) const

◆ GetSortOrder()

template<class T >
JListT::SortOrder JAliasArray< T >::GetSortOrder ( ) const

◆ Receive()

template<class T >
void JAliasArray< T >::Receive ( JBroadcaster sender,
const Message message 
)
overrideprotectedvirtual

Process the given message from the given sender. This function is not pure virtual because not all classes will want to implement it.

Reimplemented from JBroadcaster.

◆ ReceiveGoingAway()

template<class T >
void JAliasArray< T >::ReceiveGoingAway ( JBroadcaster sender)
overrideprotectedvirtual

The given sender has been deleted.

Warning: Since this function may be called from within a -chain- of destructors, it is not usually safe to do anything inside this function other than directly changing instance variables (e.g. setting pointers to nullptr).

This function is not pure virtual because not all classes will want to implement it.

Reimplemented from JBroadcaster.

◆ SearchSorted()

template<class T >
bool JAliasArray< T >::SearchSorted ( const T &  target,
const JListT::SearchReturn  which,
JIndex index 
) const

Returns true if the specified target is found.

"which" specifies what to return if more than one item matches the given target.

◆ SearchSortedOTI()

template<class T >
JIndex JAliasArray< T >::SearchSortedOTI ( const T &  target,
const JListT::SearchReturn  which,
bool found 
) const

Returns index where the item is or where it should be inserted in order to keep the list sorted. If there is an item that matches the given one, *found is set to true.

"which" specifies what to return if more than one item matches the given target.

◆ SetCompareFunction()

template<class T >
void JAliasArray< T >::SetCompareFunction ( const std::function< std::weak_ordering(const T &, const T &)>  compareFn)

◆ SetItem()

template<class T >
void JAliasArray< T >::SetItem ( const JIndex  index,
const T &  data 
)

◆ SetItemFromEnd()

template<class T >
void JAliasArray< T >::SetItemFromEnd ( const JIndex  index,
const T &  data 
)

◆ SetSortOrder()

template<class T >
void JAliasArray< T >::SetSortOrder ( const JListT::SortOrder  order)

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