- An overload for length() that allows datums to report their size in a meaningful way.
- An overload for "for (x in y)" that allows datums to be interrogated for the next item to supply to the loop (and, unavoidably I think, one for when the loop is ended).
- An overload for "if (x in y)".
For example, I might have
/tree
var/node/__head
var/list/node/__to_visit
/tree/New()
__head = new
/tree/operator+=(entry) // just for illustration
var/node/node = __head
while (TRUE)
if (!node.data)
node.data = entry
break
if (entry > node.data)
if (!node.right)
node.right = new /node
node = node.right
else if (entry < node.data)
if (!node.left)
node.left = new /node
node = node.left
// this might need some magic parameter that can be returned
// to signal an end of items rather than just a null
/tree/proc/operator_for()
if (!__to_visit)
__to_visit = list(__head)
var/last = length(__to_visit)
if (!last)
return
var/node/node = __to_visit[last]
--__to_visit.len
if (node.right)
__to_visit += node.right
if (node.left)
__to_visit += node.left
return node
/tree/proc/operator_for_done()
__to_visit = null
// horrendous, but for the point-
/tree/proc/operator_length()
var/count = 0
for (var/node in src)
++count
return count
/tree/proc/operator_in(entry)
for (var/node/node in src)
if (node.data == entry)
return TRUE
return FALSE