Skip to content

SortedMap.gaml

Loïc SADOU edited this page Sep 21, 2020 · 4 revisions

SortedMap.gaml is a species that manages to always represents a sorted list of lists.

  • Attributes

    • data (list<list>): this is where all the data is stored, this attributes is type list so the SortedMap can manage collection as input structure. The first element of the each input list has to a float, this float is the element on which data is sorted.
  • Reflex

  • Action

    • void add (list list_to_add): add the input list_to_add in data using insertion sort algorithm.
    • list get (int index): return the data element presents at index.
    • bool isEmpty (void): return true if data is empty, return false if not.
    • list remove (int index): remove the element presents at index from data.
    • int indexSearch (float sorted_number): implementation of iterative dichotomic search, return an int i like: data[i][0] <= sorted_number and data[i+1][0] > sorted_number . This action is used by add action. /!\ if there is no element in data inferior to sorted_number then indexSearch returns -1.
  • Experiment

Clone this wiki locally