#!/usr/local/bin/tclsh



proc doit {newkey} {
	global myarray
	global clocknow

	# store a new value into the array
	set myarray($newkey) $clocknow

	# clean out the array of older records.
	foreach {key val} [array get myarray] {
		if {$val <= $clocknow - 2000} {
			unset myarray($key)
		}
	}

}

set clocknow 1
for {set i 0} {$i < 10000000} {incr i} {

	set foo [list "icao" "3C6511" "lat" "48.32737" "lon" "11.71078" "alt" 2750 "callsign" "DLH722" "speed" 183 "vspeed" 1664 "heading" "203" "squawk" "3613" "mtime" "1408040536" "postime" $clocknow]
	lappend foo "moo1" "cow" "moo1" "cow" "moo1" "cow" "moo1" "cow" "moo1" "cow"
	lappend foo "moo2" "cow" "moo2" "cow" "moo2" "cow" "moo2" "cow" "moo2" "cow"
	lappend foo "moo3" "cow" "moo3" "cow" "moo3" "cow" "moo3" "cow" "moo3" "cow"

	doit $foo

	incr clocknow

	if {$i % 500 == 0} {
		puts "myarray has currently [array size myarray] elements"
	}
}

after 1000 {puts "done"}
vwait ::die