- Joined
- Jul 10, 2007
- Messages
- 6,306
Actually, since the wikipedia page might confuse people, I will put up a link I found on it.
method search takes thistype val returns thistype
if (table.has(val)) then
return table[val]
endif
return 0
endmethod
method search takes thistype val returns thistype
return return table[val]
endmethod
return return
? return $return
if (not low) then
if (v[this].lessThan(val)) then
set this=next
endif
if (v[this].greaterThan(val)) then
return this
endif
else
if (v[this].greaterThan(val)) then
set this=prev
endif
if (v[this].lessThan(val)) then
return this
endif
endif
//Should be:
if low then
if (v[this].greaterThan(val)) then
set this=prev
endif
if (v[this].lessThan(val)) then
return this
endif
else
if (v[this].lessThan(val)) then
set this=next
endif
if (v[this].greaterThan(val)) then
return this
endif
endif
See where adding safety (non-debug) can be useful?
Uh, I only implement non debug safety when the thing can break with all valid arguments and valid usage. For example, clear can break when used correctly.
I don't add safety for checking against invalid arguments or invalid usage. For example, calling deallocate 2x in a row (invalid usage) or passing a deallocated node to be added to a list (invalid argument).