SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 16/07/2018, 08:06 PM   #1
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,046
Reputation: 359
Default Vector implementation in PAWN

Vector implementation in PAWN


Description
This is a vector data structure implementation in PAWN.


Project
The source code and documentation are located at GitHub: https://github.com/BigETI/pawn-vector
BigETI is offline   Reply With Quote
Old 16/07/2018, 08:11 PM   #2
TroS
Little Clucker
 
Join Date: May 2018
Posts: 32
Reputation: 1
Default Re: Vector implementation in PAWN

Good job!
TroS is offline   Reply With Quote
Old 19/07/2018, 07:12 AM   #3
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,046
Reputation: 359
Default Re: Vector implementation in PAWN

Quote:
Originally Posted by TroS View Post
Good job!
Quote:
Originally Posted by [HLF]Southclaw View Post
Finally, my favourite data structure! (sorry, unsorted_map)
thank you
BigETI is offline   Reply With Quote
Old 19/07/2018, 07:23 AM   #4
TommyB
Banned
 
Join Date: Sep 2010
Location: Texas, USA.
Posts: 192
Reputation: 228
Default Re: Vector implementation in PAWN

BigETI making PAWN slightly more bearable one include at a time. :^)
TommyB is offline   Reply With Quote
Old 19/07/2018, 07:29 AM   #5
BigETI
Banned
 
Join Date: Mar 2010
Location: Germany
Posts: 1,046
Reputation: 359
Default Re: Vector implementation in PAWN

Quote:
Originally Posted by TommyB View Post
BigETI making PAWN slightly more bearable one include at a time. :^)
thank brother <3
BigETI is offline   Reply With Quote
Old 19/07/2018, 07:30 AM   #6
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 576
Reputation: 134
Default Re: Vector implementation in PAWN

Mashallah
iLearner is offline   Reply With Quote
Old 19/07/2018, 08:40 AM   #7
CodeStyle175
Banned
 
Join Date: Apr 2014
Posts: 455
Reputation: 35
Default Re: Vector implementation in PAWN

for what system its useful in samp, because samp is so basic
and i really doubt that code written in pawn, does the same level things as other programming languages.
CodeStyle175 is offline   Reply With Quote
Old 19/07/2018, 09:03 AM   #8
GhostHacker9
Big Clucker
 
GhostHacker9's Avatar
 
Join Date: Jan 2017
Location: New Zealand
Posts: 105
Reputation: 109
Default Re: Vector implementation in PAWN

Quote:
Originally Posted by CodeStyle175 View Post
for what system its useful in samp, because samp is so basic
and i really doubt that code written in pawn, does the same level things as other programming languages.
what you trying to say?
GhostHacker9 is offline   Reply With Quote
Old 12/10/2018, 09:36 AM   #9
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,227
Reputation: 205
Default Re: Vector implementation in PAWN

Very useful include. I can use it as a stack for a non-recursive backtracking.

For anyone interested, I needed a random shuffle for one of my vectors. It is based on Fisher-Yates's algorithm (modern version):
pawn Code:
VECTOR_random_shuffle(Vector: vector, first, last)
{
    for (new i = (last - first) - 1; i > 0; --i)
    {
        VECTOR_swap(vector, i, random(i + 1));
    }
}

VECTOR_swap(Vector: vector, a, b)
{
    new a_value = VECTOR_get_val(vector, a);
   
    VECTOR_set_val(vector, a, VECTOR_get_val(vector, b));
    VECTOR_set_val(vector, b, a_value);
}

pawn Code:
// Example:
public OnGameModeInit()
{
    new Vector: vector;
   
    for (new i = 1; i <= 10; i++)
    {
        VECTOR_push_back_val(vector, i);
    }
   
    VECTOR_random_shuffle(vector, 0, VECTOR_size(vector));
   
    VECTOR_foreach(v : vector)
    {
        printf("%d", MEM_get_val(v));
    }
    return 1;
}
Although it is still random shuffle, I prefer using MerRandom plugin.
Calisthenics is offline   Reply With Quote
Old 27/10/2018, 12:10 PM   #10
2Col
Little Clucker
 
Join Date: Nov 2017
Posts: 26
Reputation: 0
Default Re: Vector implementation in PAWN

Is it possible to set float values?
2Col is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Hash-map implementation in PAWN BigETI Includes 5 21/11/2018 11:19 PM
[Plugin] Non-recursive QuickSort implementation for PAWN ThePhenix Plugin Development 5 03/10/2018 02:43 AM
[Include] Linked list implementation in PAWN BigETI Includes 6 03/05/2018 05:42 PM
Quicksort algorithm implementation arad55 Scripting Help 2 26/07/2017 03:17 PM
Streamer implementation problems rt-2 Scripting Help 3 07/10/2011 06:23 AM


All times are GMT. The time now is 03:39 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.