OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::LinkedListPointer< ObjectType > Class Template Reference

#include <juce_LinkedListPointer.h>

Classes

class  Appender
 

Public Member Functions

 LinkedListPointer () noexcept
 
 LinkedListPointer (ObjectType *const headItem) noexcept
 
LinkedListPointeroperator= (ObjectType *const newItem) noexcept
 
 LinkedListPointer (LinkedListPointer &&other) noexcept
 
LinkedListPointeroperator= (LinkedListPointer &&other) noexcept
 
 operator ObjectType * () const noexcept
 
ObjectTypeget () const noexcept
 
LinkedListPointergetLast () noexcept
 
int size () const noexcept
 
LinkedListPointeroperator[] (int index) noexcept
 
const LinkedListPointeroperator[] (int index) const noexcept
 
bool contains (const ObjectType *const itemToLookFor) const noexcept
 
void insertNext (ObjectType *const newItem)
 
void insertAtIndex (int index, ObjectType *newItem)
 
ObjectTypereplaceNext (ObjectType *const newItem) noexcept
 
void append (ObjectType *const newItem)
 
void addCopyOfList (const LinkedListPointer &other)
 
ObjectTyperemoveNext () noexcept
 
void remove (ObjectType *const itemToRemove)
 
void deleteAll ()
 
LinkedListPointerfindPointerTo (ObjectType *const itemToLookFor) noexcept
 
void copyToArray (ObjectType **destArray) const noexcept
 
void swapWith (LinkedListPointer &other) noexcept
 

Detailed Description

template<class ObjectType>
class juce::LinkedListPointer< ObjectType >

Helps to manipulate singly-linked lists of objects.

For objects that are designed to contain a pointer to the subsequent item in the list, this class contains methods to deal with the list. To use it, the ObjectType class that it points to must contain a LinkedListPointer called nextListItem, e.g.

struct MyObject
{
int x, y, z;
// A linkable object must contain a member with this name and type, which must be
// accessible by the LinkedListPointer class. (This doesn't mean it has to be public -
// you could make your class a friend of a LinkedListPointer<MyObject> instead).
};
myList.append (new MyObject());
myList.append (new MyObject());
int numItems = myList.size(); // returns 2
int size() const noexcept
Definition juce_Array.h:215
ElementType getLast() const noexcept
Definition juce_Array.h:300

Definition at line 56 of file juce_LinkedListPointer.h.

Constructor & Destructor Documentation

◆ LinkedListPointer() [1/3]

template<class ObjectType >
juce::LinkedListPointer< ObjectType >::LinkedListPointer ( )
inlinenoexcept

Creates a null pointer to an empty list.

Definition at line 61 of file juce_LinkedListPointer.h.

◆ LinkedListPointer() [2/3]

template<class ObjectType >
juce::LinkedListPointer< ObjectType >::LinkedListPointer ( ObjectType *const  headItem)
inlineexplicitnoexcept

Creates a pointer to a list whose head is the item provided.

Definition at line 67 of file juce_LinkedListPointer.h.

◆ LinkedListPointer() [3/3]

template<class ObjectType >
juce::LinkedListPointer< ObjectType >::LinkedListPointer ( LinkedListPointer< ObjectType > &&  other)
inlinenoexcept

Definition at line 79 of file juce_LinkedListPointer.h.

Member Function Documentation

◆ addCopyOfList()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::addCopyOfList ( const LinkedListPointer< ObjectType > &  other)
inline

Creates copies of all the items in another list and adds them to this one. This will use the ObjectType's copy constructor to try to create copies of each item in the other list, and appends them to this list.

Definition at line 236 of file juce_LinkedListPointer.h.

◆ append()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::append ( ObjectType *const  newItem)
inline

Adds an item to the end of the list.

This operation involves iterating the whole list, so can be slow - if you need to append a number of items to your list, it's much more efficient to use the Appender class than to repeatedly call append().

Definition at line 227 of file juce_LinkedListPointer.h.

◆ contains()

template<class ObjectType >
bool juce::LinkedListPointer< ObjectType >::contains ( const ObjectType *const  itemToLookFor) const
inlinenoexcept

Returns true if the list contains the given item.

Definition at line 167 of file juce_LinkedListPointer.h.

◆ copyToArray()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::copyToArray ( ObjectType **  destArray) const
inlinenoexcept

Copies the items in the list to an array. The destArray must contain enough elements to hold the entire list - no checks are made for this!

Definition at line 309 of file juce_LinkedListPointer.h.

◆ deleteAll()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::deleteAll ( )
inline

Iterates the list, calling the delete operator on all of its elements and leaving this pointer empty.

Definition at line 276 of file juce_LinkedListPointer.h.

Referenced by juce::XmlElement::removeAllAttributes(), and juce::XmlElement::~XmlElement().

◆ findPointerTo()

template<class ObjectType >
LinkedListPointer * juce::LinkedListPointer< ObjectType >::findPointerTo ( ObjectType *const  itemToLookFor)
inlinenoexcept

Finds a pointer to a given item. If the item is found in the list, this returns the pointer that points to it. If the item isn't found, this returns null.

Definition at line 290 of file juce_LinkedListPointer.h.

Referenced by juce::LinkedListPointer< ObjectType >::remove().

◆ get()

template<class ObjectType >
ObjectType * juce::LinkedListPointer< ObjectType >::get ( ) const
inlinenoexcept

Returns the item which this pointer points to.

Definition at line 102 of file juce_LinkedListPointer.h.

Referenced by juce::XmlElement::isEquivalentTo(), juce::XmlElement::setAttribute(), and juce::NamedValueSet::setFromXmlAttributes().

◆ getLast()

template<class ObjectType >
LinkedListPointer & juce::LinkedListPointer< ObjectType >::getLast ( )
inlinenoexcept

Returns the last item in the list which this pointer points to. This will iterate the list and return the last item found. Obviously the speed of this operation will be proportional to the size of the list. If the list is empty the return value will be this object. If you're planning on appending a number of items to your list, it's much more efficient to use the Appender class than to repeatedly call getLast() to find the end.

Definition at line 114 of file juce_LinkedListPointer.h.

Referenced by juce::LinkedListPointer< ObjectType >::append().

◆ insertAtIndex()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::insertAtIndex ( int  index,
ObjectType newItem 
)
inline

Inserts an item at a numeric index in the list. Obviously this will involve iterating the list to find the item at the given index, so be careful about the impact this may have on execution time.

Definition at line 192 of file juce_LinkedListPointer.h.

◆ insertNext()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::insertNext ( ObjectType *const  newItem)
inline

Inserts an item into the list, placing it before the item that this pointer currently points to.

Definition at line 180 of file juce_LinkedListPointer.h.

◆ operator ObjectType *()

template<class ObjectType >
juce::LinkedListPointer< ObjectType >::operator ObjectType * ( ) const
inlinenoexcept

Returns the item which this pointer points to.

Definition at line 96 of file juce_LinkedListPointer.h.

◆ operator=() [1/2]

template<class ObjectType >
LinkedListPointer & juce::LinkedListPointer< ObjectType >::operator= ( LinkedListPointer< ObjectType > &&  other)
inlinenoexcept

Definition at line 85 of file juce_LinkedListPointer.h.

◆ operator=() [2/2]

template<class ObjectType >
LinkedListPointer & juce::LinkedListPointer< ObjectType >::operator= ( ObjectType *const  newItem)
inlinenoexcept

Sets this pointer to point to a new list.

Definition at line 73 of file juce_LinkedListPointer.h.

◆ operator[]() [1/2]

template<class ObjectType >
const LinkedListPointer & juce::LinkedListPointer< ObjectType >::operator[] ( int  index) const
inlinenoexcept

Returns the item at a given index in the list. Since the only way to find an item is to iterate the list, this operation can obviously be slow, depending on its size, so you should be careful when using this in algorithms.

Definition at line 156 of file juce_LinkedListPointer.h.

◆ operator[]() [2/2]

template<class ObjectType >
LinkedListPointer & juce::LinkedListPointer< ObjectType >::operator[] ( int  index)
inlinenoexcept

Returns the item at a given index in the list. Since the only way to find an item is to iterate the list, this operation can obviously be slow, depending on its size, so you should be careful when using this in algorithms.

Definition at line 142 of file juce_LinkedListPointer.h.

◆ remove()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::remove ( ObjectType *const  itemToRemove)
inline

Removes a specific item from the list. Note that this will not delete the item, it simply unlinks it from the list.

Definition at line 267 of file juce_LinkedListPointer.h.

◆ removeNext()

template<class ObjectType >
ObjectType * juce::LinkedListPointer< ObjectType >::removeNext ( )
inlinenoexcept

Removes the head item from the list. This won't delete the object that is removed, but returns it, so the caller can delete it if necessary.

Definition at line 251 of file juce_LinkedListPointer.h.

◆ replaceNext()

template<class ObjectType >
ObjectType * juce::LinkedListPointer< ObjectType >::replaceNext ( ObjectType *const  newItem)
inlinenoexcept

Replaces the object that this pointer points to, appending the rest of the list to the new object, and returning the old one.

Definition at line 209 of file juce_LinkedListPointer.h.

◆ size()

template<class ObjectType >
int juce::LinkedListPointer< ObjectType >::size ( ) const
inlinenoexcept

Returns the number of items in the list. Obviously with a simple linked list, getting the size involves iterating the list, so this can be a lengthy operation - be careful when using this method in your code.

Definition at line 128 of file juce_LinkedListPointer.h.

Referenced by juce::XmlElement::getNumAttributes().

◆ swapWith()

template<class ObjectType >
void juce::LinkedListPointer< ObjectType >::swapWith ( LinkedListPointer< ObjectType > &  other)
inlinenoexcept

Swaps this pointer with another one

Definition at line 318 of file juce_LinkedListPointer.h.


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