//[of]:description //[c]Safe Vector //[c] //[c]This vector is especially design to allows deletion of an item while //[c]enumerating the content. //[c] //[c]This vector can not include nil values. //[cf] //[of]:imports //[c] import "base/types" import "collection/vector" //[cf] //[of]:structure //[c] public struct safe vector: local vector // empty end //[cf] //[c] //[of]:adding - removing //[of]:add (m, object) //[c] public func add (m: safe vector, o: object) def i = 0:d def n = size (m) while i < n if is nil (m[i]) m[i] = o return end ++i end add (super (m), o) end //[cf] //[of]:remove (m, object) //[c] public func remove (m: safe vector, o: object) def i = index (m, o) if i <> -1 m [i] = nil end end //[cf] //[cf] //[of]:enumerating //[c]Enumerates all items //[c] public equ each (m: safe vector) each (super (m)) ? e if not nil (e) yield (e) end end end //[cf]