#import "grid.h"

#define __USE_FIXED_PROTOTYPES__   // for gcc headers
#include <stdio.h>

int main(void)
{
  id aZone, aMap, aTurtle, key, index;
  int i;
  char buffer[10];

  initModule( grid );

  aZone = [Zone create: globalZone];
  aMap  = [Map create: aZone];

  printf( "count: %d\n", [aMap count] );

  for ( i = 0; i < 10; i++ ) {
    aTurtle = [GridTurtle create: aZone];
    [aTurtle turn: -1];
    [aTurtle move: i * 10];
    sprintf( buffer, "%d", i );
    key = [String create: aZone setC: buffer];
    [aMap at: key insert: aTurtle];
  }

  printf( "count: %d\n", [aMap count] );

  index = [aMap begin: aZone];
  while ( (aTurtle = [index next]) ) {
    printf( "%s: ", [[index getKey] getC] );
    [aTurtle print];
  }
  [index drop];

  [[aMap first] print];
  [[aMap last] print];
  return 0;
}
