BFLibCPP 0.1
CPP Library
Loading...
Searching...
No Matches
BF::List< L, S > Class Template Reference

#include <list.hpp>

Inheritance diagram for BF::List< L, S >:
Collaboration diagram for BF::List< L, S >:

Classes

class  Iterator
 
class  Node
 

Public Member Functions

 List ()
 
 List (const std::initializer_list< L > &list)
 
virtual ~List ()
 
count () const
 
int add (L obj)
 
int pluckObject (L obj)
 
int deleteObjectAtIndex (S index)
 
int insertObjectAtIndex (L obj, S index)
 
void deleteAll ()
 
objectAtIndex (S index) const
 
void setDeallocateCallback (void(*callback)(L obj))
 
void setReleaseCallback (void(*callback)(L obj))
 
void setCompareCallback (int(*callback)(L a, L b))
 
Nodefirst () const
 
Nodelast () const
 
bool contains (const L obj)
 
void print ()
 
int sort ()
 
int sort (const ListSortOptions option)
 
int shuffle ()
 
void operator= (const std::initializer_list< L > &list)
 
Iterator begin ()
 required interfaces: begin() & end()
 
Iterator end ()
 
- Public Member Functions inherited from BF::Object
 Object ()
 
 Object (Object &obj)
 
virtual ~Object ()
 

Protected Member Functions

int deleteNode (Node *node)
 

Additional Inherited Members

- Static Public Member Functions inherited from BF::Object
static void retain (Object *obj)
 
static void release (Object *obj)
 
static int retainCount (Object *obj)
 
static int retainCount (Object &obj)
 

Detailed Description

template<typename L, typename S = int>
class BF::List< L, S >

Linked List implementation

Essentially a mutable array

L = object/data type this list will hold onto S = This object has a counter of type S. Default is a 32 bit integer. If you are planning to have a list with size exceeding the 2^32, you should change the S value to 'long' or 'long long'

Memory: Unless a callback is specified, by default the node object memory will not be deallocated.

Constructor & Destructor Documentation

◆ List() [1/2]

template<typename L , typename S = int>
BF::List< L, S >::List ( )
inline

◆ List() [2/2]

template<typename L , typename S = int>
BF::List< L, S >::List ( const std::initializer_list< L > & list)
inline

◆ ~List()

template<typename L , typename S = int>
virtual BF::List< L, S >::~List ( )
inlinevirtual
Here is the call graph for this function:

Member Function Documentation

◆ add()

template<typename L , typename S = int>
int BF::List< L, S >::add ( L obj)
inline

◆ begin()

template<typename L , typename S = int>
Iterator BF::List< L, S >::begin ( )
inline

required interfaces: begin() & end()

Here is the call graph for this function:

◆ contains()

template<typename L , typename S = int>
bool BF::List< L, S >::contains ( const L obj)
inline

Checks if there is at least one node with obj

◆ count()

template<typename L , typename S = int>
S BF::List< L, S >::count ( ) const
inline

◆ deleteAll()

template<typename L , typename S = int>
void BF::List< L, S >::deleteAll ( )
inline

◆ deleteNode()

template<typename L , typename S = int>
int BF::List< L, S >::deleteNode ( Node * node)
inlineprotected

Delete node but does not delete object

◆ deleteObjectAtIndex()

template<typename L , typename S = int>
int BF::List< L, S >::deleteObjectAtIndex ( S index)
inline

deletes object at the index

index: must not exceed bounds of array

Here is the call graph for this function:

◆ end()

template<typename L , typename S = int>
Iterator BF::List< L, S >::end ( )
inline

◆ first()

template<typename L , typename S = int>
Node * BF::List< L, S >::first ( ) const
inline

Returns the head of the list

Caller can use this node to traverse through the list

◆ insertObjectAtIndex()

template<typename L , typename S = int>
int BF::List< L, S >::insertObjectAtIndex ( L obj,
S index )
inline

Insert obj at index. Will push every object after an index

index: must be within range of list.

Here is the call graph for this function:

◆ last()

template<typename L , typename S = int>
Node * BF::List< L, S >::last ( ) const
inline

◆ objectAtIndex()

template<typename L , typename S = int>
L BF::List< L, S >::objectAtIndex ( S index) const
inline
Here is the call graph for this function:

◆ operator=()

template<typename L , typename S = int>
void BF::List< L, S >::operator= ( const std::initializer_list< L > & list)
inline

◆ pluckObject()

template<typename L , typename S = int>
int BF::List< L, S >::pluckObject ( L obj)
inline

finds object and removes from list

DOES NOT DELETE MEMORY

Here is the call graph for this function:

◆ print()

template<typename L , typename S = int>
void BF::List< L, S >::print ( )
inline

Prints entire list

Here is the call graph for this function:

◆ setCompareCallback()

template<typename L , typename S = int>
void BF::List< L, S >::setCompareCallback ( int(* callback )(L a, L b))
inline

Sets the callback we use when sorting

◆ setDeallocateCallback()

template<typename L , typename S = int>
void BF::List< L, S >::setDeallocateCallback ( void(* callback )(L obj))
inline

callback will be a pointer to a function that handles how we will delete object memory

◆ setReleaseCallback()

template<typename L , typename S = int>
void BF::List< L, S >::setReleaseCallback ( void(* callback )(L obj))
inline

sets release callback

◆ shuffle()

template<typename L , typename S = int>
int BF::List< L, S >::shuffle ( )
inline

Shuffles node links

Here is the call graph for this function:

◆ sort() [1/2]

template<typename L , typename S = int>
int BF::List< L, S >::sort ( )
inline

Default sort kListSortOptionsDefault

Here is the call graph for this function:

◆ sort() [2/2]

template<typename L , typename S = int>
int BF::List< L, S >::sort ( const ListSortOptions option)
inline

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