[Plugin] CSTL - Data container(s) (Currently vector)
#47

Just did these defines for enumerating through vector easily. Vector must only contain entries of same data type.
Код:
#define vector_enum_cell<%0,%1> for (new _%0_it = 0, %1 = 0 ; (_%0_it < vector_size(%0) && (%1 = vector_get(%0,_%0_it)))  ; _%0_it++)
#define vector_enum_float<%0,%1> for (new _%0_it = 0, Float:%1 = 0 ; (_%0_it < vector_size(%0) && (%1 = vector_get_float(%0,_%0_it)))  ; _%0_it++)
#define vector_enum_arr<%0,%1,%2> for (new _%0_it = 0, %1[%2] ; (_%0_it < vector_size(%0) && (vector_get_arr(%0,_%0_it,%1,%2)))  ; _%0_it++)
Example usage:

Код:
	new vector_id = 0, index = 0;

	vector_push_back_arr(vector_id, "Hello, World!");
	vector_push_back_arr(vector_id, "Hello to you too.");
	
	vector_enum_arr<vector_id, curStr, 128>
	{
	    printf("index %i: %s", index, curStr);
	    index++;
	}
	vector_clear(vector_id);
Prints
0: Hello, World!
1: Hello to you too.


How-to use:

Код:
vector_enum_cell<vectorid, currentcell>
Specify vector to enumerate in vectorid.
Specify variable name to store current cell.

vector_enum_float<vectorid, currentfloat>
Specify vector to enumerate in vectorid.
Specify variable name to store current float.

vector_enum_arr<vectorid, currentarr, length>
Specify vector to enumerate in vectorid.
Specify variable name to store current array.
Specify length for currentarr (if vector contains array larger than it, its truncated)
Index of current entry is stored in variable named "_X_it" where X is vector id specified in vectorid (if you specified a variable there, X will be variable name, not the content). So its not suggested to use this. Better to use your own index variable like in example.

These defines can be put into cstl.inc file for easy usage.
Reply


Messages In This Thread
CSTL - Data containers (Vector, Map) - by Teprey - 12.03.2011, 13:38
Re: CSTL - Data container(s) (Currently vector) - by Zh3r0 - 12.03.2011, 14:24
Re: CSTL - Data container(s) (Currently vector) - by TheArcher - 12.03.2011, 14:59
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 12.03.2011, 15:08
Re: CSTL - Data container(s) (Currently vector) - by Zh3r0 - 12.03.2011, 15:12
Re: CSTL - Data container(s) (Currently vector) - by [L3th4l] - 12.03.2011, 15:18
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 12.03.2011, 15:41
Re: CSTL - Data container(s) (Currently vector) - by Dreftas - 12.03.2011, 16:41
Re: CSTL - Data container(s) (Currently vector) - by Medal Of Honor team - 12.03.2011, 17:03
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 12.03.2011, 18:27
Re: CSTL - Data container(s) (Currently vector) - by hencz - 12.03.2011, 18:45
Re: CSTL - Data container(s) (Currently vector) - by anonymousx - 12.03.2011, 18:54
Re: CSTL - Data container(s) (Currently vector) - by 1337connor - 12.03.2011, 19:11
Re: CSTL - Data container(s) (Currently vector) - by xxmitsu - 12.03.2011, 19:17
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 12.03.2011, 19:27
Re: CSTL - Data container(s) (Currently vector) - by Patrik356b - 12.03.2011, 19:38
Re: CSTL - Data container(s) (Currently vector) - by RyDeR` - 12.03.2011, 22:35
Re: CSTL - Data container(s) (Currently vector) - by CyNiC - 13.03.2011, 03:05
Re: CSTL - Data container(s) (Currently vector) - by anonymousx - 13.03.2011, 07:45
Re: CSTL - Data container(s) (Currently vector) - by Kyosaur - 13.03.2011, 07:54
Re: CSTL - Data container(s) (Currently vector) - by Minokon - 13.03.2011, 09:39
Re: CSTL - Data container(s) (Currently vector) - by Macluawn - 13.03.2011, 15:35
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 14.03.2011, 13:54
Re: CSTL - Data container(s) (Currently vector) - by XFlawless - 14.03.2011, 14:22
Re: CSTL - Data container(s) (Currently vector) - by RyDeR` - 14.03.2011, 15:42
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 14.03.2011, 16:08
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 14.03.2011, 20:33
Re: CSTL - Data container(s) (Currently vector) - by Kyosaur - 15.03.2011, 05:19
Re: CSTL - Data container(s) (Currently vector) - by SlashPT - 15.03.2011, 06:58
Re: CSTL - Data container(s) (Currently vector) - by Macluawn - 15.03.2011, 07:05
Re: CSTL - Data container(s) (Currently vector) - by Retardedwolf - 15.03.2011, 10:00
Re: CSTL - Data container(s) (Currently vector) - by Slice - 15.03.2011, 11:43
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 15.03.2011, 12:25
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 15.03.2011, 15:18
Re: CSTL - Data container(s) (Currently vector) - by iggy1 - 21.03.2011, 08:42
Re: CSTL - Data container(s) (Currently vector) - by CaHbKo - 14.06.2011, 09:09
Re: CSTL - Data container(s) (Currently vector) - by Calgon - 14.06.2011, 09:16
Re: CSTL - Data container(s) (Currently vector) - by 0x5A656578 - 14.06.2011, 10:47
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 14.06.2011, 15:36
Re: CSTL - Data container(s) (Currently vector) - by CaHbKo - 19.06.2011, 12:07
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 19.06.2011, 15:19
Re: CSTL - Data container(s) (Currently vector) - by Macluawn - 24.06.2011, 21:48
Re: CSTL - Data container(s) (Currently vector) - by linuxthefish - 24.06.2011, 22:28
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 29.06.2011, 11:54
Re: CSTL - Data container(s) (Currently vector) - by GangsTa_ - 29.06.2011, 15:00
Re: CSTL - Data container(s) (Currently vector) - by iggy1 - 29.06.2011, 17:12
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 30.06.2011, 10:32
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 14.07.2011, 11:28
Re: CSTL - Data container(s) (Currently vector) - by Dreftas - 25.08.2011, 10:10
Re: CSTL - Data container(s) (Currently vector) - by papedo - 16.09.2011, 17:11
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 18.10.2011, 15:26
Re: CSTL - Data container(s) (Currently vector) - by Slice - 18.10.2011, 16:03
Re: CSTL - Data container(s) (Currently vector) - by SourceCode - 18.10.2011, 16:12
Re: CSTL - Data container(s) (Currently vector) - by Teprey - 18.10.2011, 19:11
Re: CSTL - Data container(s) (Currently vector) - by Babul - 20.10.2011, 18:22
Re: CSTL - Data container(s) (Currently vector) - by AndreT - 04.12.2011, 09:19
Re: CSTL - Data container(s) (Currently vector) - by SchurmanCQC - 07.01.2012, 19:40
Re: CSTL - Data container(s) (Currently vector) - by cyber_punk - 07.07.2012, 01:58
Re: CSTL - Data container(s) (Currently vector) - by AndreT - 07.07.2012, 06:16
Re: CSTL - Data container(s) (Currently vector) - by cyber_punk - 10.07.2012, 00:26
Re: CSTL - Data container(s) (Currently vector) - by Yiin - 09.05.2013, 13:05
Re: CSTL - Data container(s) (Currently vector) - by RCON1 - 22.09.2013, 09:34
Re: CSTL - Data container(s) (Currently vector) - by OxyG3N - 07.01.2014, 10:54
Re: CSTL - Data container(s) (Currently vector) - by detter - 12.01.2014, 15:29
Re: CSTL - Data container(s) (Currently vector) - by Michalec - 12.12.2015, 22:36

Forum Jump:


Users browsing this thread: 1 Guest(s)