5747020 [rkeene@sledge /home/rkeene/projects/d]$ cat -n associative_arrays.d
   1: import std.file;
   2: import std.stream;
   3: 
   4: int main(char args[][]) {
   5: 	char[][char[]] hashtable;
   6: 
   7: 	hashtable["joe"] = "bob";
   8: 	hashtable["sally"] = "Once";
   9: 
  10: 	foreach (char ent[]; hashtable.keys) {
  11: 		stdout.printf("%.*s = %.*s\n", ent, hashtable[ent]);
  12: 	}
  13: 
  14: 	return(0);
  15: }

associative_arrays.d is a simple example of a hash table/associative array written in D.
5747021 [rkeene@sledge /home/rkeene/projects/d]$

Click here to go back to the directory listing.
Click here to download this file.
last modified: 2005-01-20 22:06:23