//[of]:description //[c]Same as vector, but the string is owned by the array //[c](copied when added, deleted when removed) //[cf] //[of]:imports public import "base/types" public import "base/memory-allocator" public import "collection/vector" public import "text/vector-of-strings" public import "text/string" //[cf] //[of]:structures public struct array of strings : local vector of strings end //[cf] //[c] //[of]:instance creation //[of]:new array of strings (initial allocated) public equ new array of strings (initial allocated: size) = new vector (initial allocated) : array of strings //[cf] //[of]:new array of strings (vector of strings) public equ new array of strings (src: vector of strings) = new vector (src) : array of strings //[cf] //[of]:delete (v) //[c] public func delete (v: array of strings) release (v) free memory (v) end //[cf] //[cf] //[of]:intialize - release //[of]:array of strings (initial allocated) //[c] public func array of strings (initial allocated: size, return v: array of strings) initialize (v, initial allocated) end //[cf] //[of]:release (v) //[c] public func release (v: array of strings) each (v) ? s delete (s) end release (super (v)) end //[cf] //[cf] //[of]:accessing //[of]:set (a, index, value) //[c]Changes the value at index //[c] public func set (a: array of strings, index: dword, value: string) // return if unchanged if value : mem == a[index] return end delete (a[index]) set (super (a), index, new string (value)) end //[cf] //[cf] //[of]:adding - removing //[of]:add (a, value, index) //[c]Adds an element at index //[c] public func add (a: array of strings, value: string, index: dword) add (super (a), new string (value), index) end //[cf] //[of]:add first (a, value) //[c]Adds an element at the beginning //[c] public func add first (a: array of strings, value: string) add (a, value, 0) end //[cf] //[of]:add (a, value) //[c] public equ add (a: array of strings, value: string) = append (a, value) //[cf] //[of]:append (a, value) //[c]Appends an element //[c] public func append (a: array of strings, value: string) append (super (a), new string (value)) end //[cf] //[c] //[of]:add substring (a, value, size, index) //[c]Adds an element at index //[c] public func add substring (a: array of strings, value: string, size: size, index: dword) add (super (a), new string (value, size), index) end //[cf] //[of]:add first substring (a, value, size) //[c]Adds an element at the beginning //[c] public func add first substring (a: array of strings, value: string, size: size) add substring (a, value, size, 0) end //[cf] //[of]:add substring (a, value, size) //[c] public equ add substring (a: array of strings, value: string, size: size) = append substring (a, value, size) //[cf] //[of]:append substring (a, value, size) //[c]Appends an element //[c] public func append substring (a: array of strings, value: string, size: size) append (super (a), new string (value, size)) end //[cf] //[c] //[of]:remove (a, index) //[c]Removes an element at index //[c] public func remove (a: array of strings, index: dword) delete (a[index]) remove (super (a), index) end //[cf] //[of]:remove (a, value) //[c]Removes an element //[c] public func remove (a: array of strings, value: string) def i = 0:d def n = size (a) while i < n if is equal (a[i], value) remove (a, i) return end ++i end end //[cf] //[of]:remove all (a) //[c]Removes all elements //[c] public func remove all (a: array of strings) each (a) ? s delete (s) end size (a) = 0 end //[cf] //[cf]