-
Notifications
You must be signed in to change notification settings - Fork 0
ESE_Queue Class
NarcoMarshDev edited this page Oct 22, 2022
·
6 revisions
Category: Data Structure
Path: scripts/Game/Types/ESE_Queue.c
Template class for statically sized first-in, first-out array of objects.
FIFO data structure with maximum assigned size that automatically dequeues oldest entry when attempting to enqueue new entry above max size. The raw data behind the scenes is stored in reverse order for optimisation so if wanting to access it directly with ESE_Queue.Raw make sure to account for this.
Code example of creating, enqueueing entries up the max size and automatically dequeuing to make space for new entries:
auto m_Queue = new ESE_Queue<int>(5); // create queue with max size of 5
for (int i = 0; i < 5; i++)
{
m_Queue.Enqueue(i);
}
m_Queue.PrintRaw(); // >>> {4,3,2,1,0}
// add new entry to show auto dequeue of oldest entry
m_Queue.Enqueue(5);
m_Queue.PrintRaw(); // >>> {5,4,3,2,1}
// manual dequeue
int val = m_Queue.Dequeue();
m_Queue.PrintRaw(); // >>> {10,4,3,2}
Print(val); // >>> 1| Name⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ | Return⠀⠀⠀⠀⠀ | Description |
|---|