55template <
class ObjectType>
118 while (
l->item !=
nullptr)
119 l = &(
l->item->nextListItem);
132 for (
auto* i = item; i !=
nullptr; i = i->nextListItem)
146 while (--index >= 0 &&
l->item !=
nullptr)
147 l = &(
l->item->nextListItem);
160 while (--index >= 0 &&
l->item !=
nullptr)
161 l = &(
l->item->nextListItem);
169 for (
auto* i = item; i !=
nullptr; i = i->nextListItem)
182 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
187 JUCE_END_IGNORE_WARNINGS_MSVC
199 while (index != 0 &&
l->item !=
nullptr)
201 l = &(
l->item->nextListItem);
213 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011 28182)
219 item->nextListItem =
oldItem->nextListItem.item;
220 oldItem->nextListItem.item =
nullptr;
222 JUCE_END_IGNORE_WARNINGS_MSVC
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);
315 JUCE_BEGIN_IGNORE_WARNINGS_MSVC (6011)
318 for (
auto* i = item; i !=
nullptr; i = i->nextListItem)
321 JUCE_END_IGNORE_WARNINGS_MSVC
354 endOfList = &(
newItem->nextListItem);
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.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...