![]() |
data structures
boredom struck and I couldn't really find anything involving queues and stacks on the wiki (ActionMap has a push and pop which confused me) so I wrote up a queue real quick.
the most practical use I can think of for this right now is a spar system, where players joining the line are pushed on the queue, and you use a pop to get who's next in line. I'll add a stack and some other data structures potentially tomorrow when I'm not tired. queue: PHP Code:
|
That's a fairly good exercise. I remember taking a data structures course a few years ago, and we had to implement these things from scratch (sort of similar to what you did). Any chance this is inspired by such a course? :p
Just some things I noticed: You could simplify the empty() function: PHP Code:
PHP Code:
|
Quote:
I've written mostly in java, haven't done data structures since sophomore year in high school when I took AP CS AB. Was working on something earlier today, thought a queue would be useful, couldn't find a graal version anywhere. |
|
Quote:
|
Stefan should simply add pushback(), pushfront(), popback(), and popfront() functions to the TGraalVar which would allow the array to be used as a queue or stack.
|
| All times are GMT +2. The time now is 07:07 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.