set.st

来自「四皇后问题」· ST 代码 · 共 26 行

ST
26
字号
Class Set :Collection
| list |
[
        new
                list <- List new

|       add: newElement
		(list includes: newElement)
			ifFalse: [list add: newElement]

|       remove: oldElement ifAbsent: exceptionBlock
		list remove: oldElement ifAbsent: exceptionBlock

|       size
                ^ list size

|       occurrencesOf: anElement
                ^ (list includes: anElement) ifTrue: [1] ifFalse: [0]

|       first
                ^ list first

|       next
                ^ list next
]

⌨️ 快捷键说明

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