1. 线性表(Linear List):[aValue1, aValue2, aValue3, ...]
2. 属性表(Property List):[propName1: aValue1, propName2: aValue2, propName3: aValue3, ...]
3. 线性表和属性表:[item1, item2, item3, ...],其中线性表的每一个item只有一个部分aValue,而属性表的每一个item有两个部分propName和aValue。另外,我们经常用index来指代item在表中的位置,例如item1在表中的index值即为1。
二、基本表命令一览
Linear List and Property List
01. getAt():由index获取相应的aValue。
语法:getAt(myList, index)或myList.getAt(index)
02. getLast():获取最后一项的aValue。
语法:getLast(myList)或myList.getLast()
03. getOne():对于线性表,由aValue获取相应的index;对于属性表,由aValue获取相应的propName。
语法:getOne(myList, aValue)或myList.getOne(aValue)
[注] 若给出的aValue不存在则返回0。
04. getPos():由aValue获取相应的index。
语法:getPos(myList, aValue)或myList.getPos(aValue)
[注] 若给出的aValue不存在则返回0。
05. setAt:设定相应index处的aValue。
语法:setAt myList, index, aValue或myList.setAt(index, aValue)
[注] 当给出的index超出myList的范围时:对于线性表会被加长(自动给没有定义的项插入0);对于属性表会报错。
06. deleteAt:删除相应index处的item。
语法:deleteAt myList, index或myList.deleteAt(index)
[注] 若给出的index不存在则报错。
07. deleteOne:删除相应aValue处的item。
语法:deleteOne myList, aValue或myList.deleteOne(aValue)
[注] 若存在若干相同aValue的item,则删除第一个。
08. findPos():返回相应aVaule(线性表)或propName(属性表)的index。
语法:findPos(myList, aValue/propName)或myList.findPos(aValue/propName)
[注] 若给出的aValue/propName不存在,则对于线性表返回0,对于属性表返回<Void>。
09. findPosNear():返回相应aValue(线性表)或propName(属性表)被排进表后的index。
语法:findPosNear(myList, aValue/propName)或myList.findPosNear(aValue/propName)
[注] 使用findPosNear()前必须先对myList排序。否则对于线性表返回0,对于属性表返回最后一个item的index。
10. deleteProp:删除相应index(线性表)或propName(属性表)处的item。
语法:deleteProp myList, index/propName或myList.deleteProp(index/propName)
[注] 若给出的index/propName不存在则报错。
11. deleteAll:不改变表的类型,删除其中所有item。
语法:deleteAll myList或myList.deleteAll()
Only Linear List
01. addAt:在相应index处插入aValue。
语法:addAt myList, index, aValue或myList.addAt(index, aValue)
[注] 当给出的index超出myList的范围时表会被加长(自动给没有定义的项插入0)
02. add:将aValue添加到表末。
语法:add myList, aValue或myList.add(aValue)
[注]:若myList有序则aValue添加时被自动排序。
03. append:即使myList有序,也将aValue添加到表末。
语法:append myList, aValue或myList.append(aValue)
Only Property List
01. getProp():由propName获取相应的aValue。
语法:getProp(myList, propName)或myList.getProp(propName)
[注] 若给出的propName不存在则报错。
02. getAProp():由propName获取相应的aValue。
语法:getAProp(myList, propName)或myList.getAProp(propName)
[注] 若给出的propName不存在则返回<Void>。
03. getPropAt():由index获取相应的propName。
语法:getPropAt(myList, index)或myList.getPropAt(index)
[注] 若给出的index不存在则报错。
04. setProp:设定相应propName处的aValue。
语法:setProp myList, propName, aValue或myList.setProp(propName, aValue)