Raised This Month: $183 Target: $400
 45% 

[INC] Queue - FIFO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JoinedSenses
Senior Member
Join Date: Sep 2013
Old 11-04-2019 , 00:04   [INC] Queue - FIFO
Reply With Quote #1

Based on some discussion via SM discord, I created a queue methodmap which inherits from Handle and utilizes arraylist methods. Unlike ArrayStack, this methodmap is First In, First Out.

Code can be found here:
queue.inc

Simple example usage:

Code:
#include <sourcemod>
#include <queue>

public void OnPluginStart() {
	RegAdminCmd("sm_test", cmdTest, ADMFLAG_ROOT);
}

public Action cmdTest(int client, int args) {
	Queue q = new Queue();

	for (int i = 1; i <= 10; i++) {
		q.Push(i);	
	}

	while (!q.Empty) {
		ReplyToCommand(client, "%i", q.Pop());
	}

	delete q;

	return Plugin_Handled;
}
__________________

Last edited by JoinedSenses; 11-04-2019 at 00:58.
JoinedSenses is offline
Bara
AlliedModders Donor
Join Date: Apr 2012
Location: Germany
Old 11-04-2019 , 14:13   Re: [INC] Queue - FIFO
Reply With Quote #2

Thanks, will be useful for some stuff.
__________________
Discord | My Plugins (GitHub)
You like my work? Support is not a crime.
Bara is offline
HelpMe
Senior Member
Join Date: Jun 2013
Location: Home
Old 10-29-2020 , 08:36   Re: [INC] Queue - FIFO
Reply With Quote #3

Sadly pop is still O(n).
HelpMe is offline
MAGNAT2645
Senior Member
Join Date: Nov 2015
Location: AlliedMods.net
Old 10-29-2020 , 18:50   Re: [INC] Queue - FIFO
Reply With Quote #4

Quote:
Originally Posted by HelpMe View Post
Sadly pop is still O(n).
Queue is based on ArrayList so it's not surprising.
__________________
MAGNAT2645 is offline
JoinedSenses
Senior Member
Join Date: Sep 2013
Old 01-23-2021 , 16:34   Re: [INC] Queue - FIFO
Reply With Quote #5

SM doesnt have LinkedList
__________________
JoinedSenses is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:01.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode