Jump to content


Photo

GMIterator


  • Please log in to reply
4 replies to this topic

#1 fel666

fel666

    GMC Member

  • GMC Member
  • 1883 posts
  • Version:GM:Studio

Posted 02 March 2016 - 10:34 PM

GMIterator V0.1a

GMIterator adds a number of new data structures and iterators for all iterators

New data structures can be more efficient depending on the application.

This is a WIP and only some features have been added

 

GMIterator allows you to use the same sets of iterator methods over all data structures (currently ds_list and ds_linked_list).

This can neaten or simplify code when iterating and editing a set of data at the same time (ie, removing or adding elements)

 

Download: Github

 

Features:

  • doubly linked_lists​
  • linked_list iterators
  • list_iterators
  • both forwards and backwards iteration
  • remove iterated items
  • More data structures to come

 

example use:

Spoiler

 

Performance:

Spoiler

 

Future features:

Spoiler

 

please note: These scripts are in early stages of development, and some scripts are placeholders.

known issues include __GMI_ll_link_swap__ only swaping correctly ordered adjacent links (erm, probably more bugs to come)

other changes will be made to sorting algorithms (current is bubble sort, but planning on adding quicksort)


Edited by fel666, 06 March 2016 - 03:57 PM.

  • 6

This forum is old and archived, Whatever it is i said up above may no longer reflect my opinion.

GMWolf
GMIterator
RefactorTool
OptimizedDecals

#2 Zerb Games

Zerb Games

    GMC Member

  • GMC Member
  • 155 posts
  • Version:GM:Studio

Posted 02 March 2016 - 11:06 PM

Wow, this is great. GOOD JOB! +1


  • 0

-Stay Royal


#3 fel666

fel666

    GMC Member

  • GMC Member
  • 1883 posts
  • Version:GM:Studio

Posted 06 March 2016 - 03:59 PM

New minor update: I added the iterator_add function; it allows you to insert elements part-way through iteration.
before working on Sets and iterators for maps, ill implement singly linked lists: they should offer the ~2/3 the memory footprint of current (doubly) linked lists, and possibly some performance improvements, but will loose the functionality of iterating backwards.

[edit]
Ibdont know if I will add singly linked list in the end, because of the disadvantages they present.

Edited by fel666, 22 March 2016 - 12:52 PM.

  • 0

This forum is old and archived, Whatever it is i said up above may no longer reflect my opinion.

GMWolf
GMIterator
RefactorTool
OptimizedDecals

#4 Catan

Catan

    GMC Member

  • GMC Member
  • 357 posts
  • Version:Unknown

Posted 22 March 2016 - 08:49 AM

That's a great set of scripts, I like the use of buffers to speed things up. Quicksort could really be a game changer as well, since ds_list_sort performance is just terrible (using a GML implementation of quicksort is 10x faster than the built in function, and ds_grid_sort is around 100x as fast, which makes no sense at all).


  • 0

.

GMSDB - A pure GML database system

GMGL - Game updater and launcher

AutoTiles Helper - An autotiling system


#5 fel666

fel666

    GMC Member

  • GMC Member
  • 1883 posts
  • Version:GM:Studio

Posted 22 March 2016 - 12:41 PM

That's a great set of scripts, I like the use of buffers to speed things up. Quicksort could really be a game changer as well, since ds_list_sort performance is just terrible (using a GML implementation of quicksort is 10x faster than the built in function, and ds_grid_sort is around 100x as fast, which makes no sense at all).

Great! I'm glad you like it.
I really want to use quick sort too but a couple things have to be fixed before that (including the swap algorithm).
I don't know how much time I can spend on it, but I intend to open source this project.
If anyone is up for it, it'll be great if you could add quicksort or any other feature you like!

Just create a branch and after some inevitable bug fixing I'll add it to the main branch :)


Also, small change of plans: I won't be adding singly linked lists as though they do improve performance when adding or removing at the head xor the tail, they are terrible at removing or adding at the center (similar to an array list)
Therefore I'll look into making iterators for built in DS' first.
There are ways to make singly linked lists faster using more complex iterators, but the performance will be around the same as a doubly linked list, and so using a singly linked list makes little sense.

Edited by fel666, 22 March 2016 - 12:53 PM.

  • 0

This forum is old and archived, Whatever it is i said up above may no longer reflect my opinion.

GMWolf
GMIterator
RefactorTool
OptimizedDecals