⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vector-of-strings.zc

📁 实现树形结构
💻 ZC
字号:
//[of]:imports
//[c]
public import "base/types"
public import "text/string"
public import "collection/vector"
//[cf]
//[of]:structures
//[c]
public struct vector of strings : local vector
	// empty
end
//[cf]
//[c]
//[of]:instance creation
//[of]:new vector of strings (initial allocated)
//[c]
public equ new vector of strings (initial allocated: size) =

	new vector (initial allocated) : vector of strings

//[cf]
//[of]:new vector of strings (src vector)
//[c]
public equ new vector of strings (src: vector of strings) = 

	new vector (src) : vector of strings

//[cf]
//[cf]
//[of]:initialize - release
//[of]:vector of strings (initial allocated)
//[c]
public func vector of strings (initial allocated: size, return v: vector of strings)
	initialize (v, initial allocated)
end
//[cf]
//[cf]
//[of]:enumerating
//[of]:each (v)
//[c]Enumerates all strings
//[c]
public equ each (v: vector of strings)

	each (super (v)) ? item
		yield (item : string)
	end

end
//[cf]
//[cf]
//[of]:searching
//[of]:index (v, s)
//[c]Return the first index of the string or -1
//[c]
public func index (m: vector of strings, s: string)

	def i = 0:d
	def n = size (m)
	while i < n
		if is equal (s, m[i])
			return i
		end
		++ i
	end
	return -1

end
//[cf]
//[cf]
//[of]:accessing
//[of]:v [dword]
//[c]Returns an element
//[c]
public equ @at (v: vector of strings, i: dword) = 

	super (v) [i] : string
//[cf]
//[of]:set (v, index, value)
//[c]Assigns an element
//[c]
public equ set (v: vector of strings, i: dword, value: string) =
	super (v) [i] = value

//[cf]
//[cf]

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -