HexList

Name

HexList -- An Ordered List of HexTile

Synopsis


#include <hexmap.h>



struct      HexList;

HexList*    hex_list_set_tile               (HexList *list,
                                             gint depth,
                                             HexTile *tile);
void        hex_list_clear                  (HexList *list);
HexList*    hex_list_copy                   (HexList *list);

HexList*    hex_list_painter_copy           (HexList *list);
guint       hex_list_painter_hash           (HexList *list);
gboolean    hex_list_painter_equal          (HexList *list1,
                                             HexList *list2);

Description

A HexList is a singly linked list of HexTile, with the links proceeding from lowest depth to highest (painter's algorithm order). A singly linked list was used instead of a doubly linked list because it was felt that the computational losses due to reverse traversal of a (in most cases very short) HexList was offset by the savings in ram for HexGrid (especially for mind bogglingly huge grid sizes).

Details

struct HexList

struct HexList {
  HexTile     *tile;
  gint         depth;
  HexList     *next;
};

A linked list for holding HexTile pointers in depth order, lowest depth first


hex_list_set_tile ()

HexList*    hex_list_set_tile               (HexList *list,
                                             gint depth,
                                             HexTile *tile);

Set the tile at a given depth in a HexList

list :

a HexList. An empty list can be specified by passing NULL.

depth :

the depth at which to place the tile

tile :

a HexTile. Passing NULL clears the existing tile at this depth.

Returns :

The updated HexList


hex_list_clear ()

void        hex_list_clear                  (HexList *list);

Clear the contents of a HexList

list :

a HexList.


hex_list_copy ()

HexList*    hex_list_copy                   (HexList *list);

copy a HexList

list :

a HexList. An empty list can be specified by passing NULL.

Returns :

A copy of list, containing the same tiles as the original


hex_list_painter_copy ()

HexList*    hex_list_painter_copy           (HexList *list);

Return a new HexList containing the HexData from list in newly created HexTiles. Any HexData with a NULL draw function is not copied.

list :

a HexList

Returns :

the new HexList


hex_list_painter_hash ()

guint       hex_list_painter_hash           (HexList *list);

This is a hash function whose return value depends only on the HexData in list, neglecting HexData with a NULL draw function

list :

a HexList

Returns :

a hash value


hex_list_painter_equal ()

gboolean    hex_list_painter_equal          (HexList *list1,
                                             HexList *list2);

Two lists are equal under the painter's algorithm if they have the same HexData in the same order, neglecting specific depths and HexData with a NULL draw function

list1 :

a HexList

list2 :

a HexList

Returns :

TRUE if the lists are equal under the painter's algorithm, FALSE otherwise