59template <
class ObjectType>
91 jassert (
this != &other);
122 while (
l->item !=
nullptr)
123 l = &(
l->item->nextListItem);
136 for (
auto* i = item; i !=
nullptr; i = i->nextListItem)
150 while (--index >= 0 &&
l->item !=
nullptr)
151 l = &(
l->item->nextListItem);
164 while (--index >= 0 &&
l->item !=
nullptr)
165 l = &(
l->item->nextListItem);
173 for (
auto* i = item; i !=
nullptr; i = i->nextListItem)
187 jassert (
newItem->nextListItem ==
nullptr);
201 while (index != 0 &&
l->item !=
nullptr)
203 l = &(
l->item->nextListItem);
216 jassert (
newItem->nextListItem ==
nullptr);
220 item->nextListItem =
oldItem->nextListItem.item;
221 oldItem->nextListItem.item =
nullptr;
244 for (
auto* i =
other.item; i !=
nullptr; i = i->nextListItem)
262 oldItem->nextListItem.item =
nullptr;
282 while (item !=
nullptr)
298 while (
l->item !=
nullptr)
303 l = &(
l->item->nextListItem);
317 for (
auto* i = item; i !=
nullptr; i = i->nextListItem)
324 std::swap (item,
other.item);
351 endOfList = &(
newItem->nextListItem);
357 JUCE_DECLARE_NON_COPYABLE (
Appender)
Holds a resizable array of primitive or copy-by-value objects.
Allows efficient repeated insertions into a list.
Appender(LinkedListPointer &endOfListPointer) noexcept
Creates an appender which will add items to the given list.
void append(ObjectType *const newItem) noexcept
Appends an item to the list.
Helps to manipulate singly-linked lists of objects.
LinkedListPointer & getLast() noexcept
Returns the last item in the list which this pointer points to.
LinkedListPointer * findPointerTo(ObjectType *const itemToLookFor) noexcept
Finds a pointer to a given item.
LinkedListPointer & operator[](int index) noexcept
Returns the item at a given index in the list.
ObjectType * replaceNext(ObjectType *const newItem) noexcept
Replaces the object that this pointer points to, appending the rest of the list to the new object,...
void append(ObjectType *const newItem)
Adds an item to the end of the list.
void deleteAll()
Iterates the list, calling the delete operator on all of its elements and leaving this pointer empty.
LinkedListPointer & operator=(ObjectType *const newItem) noexcept
Sets this pointer to point to a new list.
bool contains(const ObjectType *const itemToLookFor) const noexcept
Returns true if the list contains the given item.
ObjectType * removeNext() noexcept
Removes the head item from the list.
LinkedListPointer(ObjectType *const headItem) noexcept
Creates a pointer to a list whose head is the item provided.
void insertNext(ObjectType *const newItem)
Inserts an item into the list, placing it before the item that this pointer currently points to.
ObjectType * get() const noexcept
Returns the item which this pointer points to.
void addCopyOfList(const LinkedListPointer &other)
Creates copies of all the items in another list and adds them to this one.
int size() const noexcept
Returns the number of items in the list.
void insertAtIndex(int index, ObjectType *newItem)
Inserts an item at a numeric index in the list.
void copyToArray(ObjectType **destArray) const noexcept
Copies the items in the list to an array.
LinkedListPointer() noexcept
Creates a null pointer to an empty list.
void swapWith(LinkedListPointer &other) noexcept
Swaps this pointer with another one.
void remove(ObjectType *const itemToRemove)
Removes a specific item from the list.