collection
Table of Contents
collection
one -to- many relationship ⇒ use a collection
OrderedCollection
dynamincally sized collection
ex
| oc | oc := OrderedCollection new: 1. 1 to: 3 do: [:n | a add: n]. ^ a an OrderedCollection(1 2 3)
RunArry
How do you compactly code (OredredCollection or Array) 예
#(plain plain plain bold bold bold bold) -대체-> 3--#plain, 4--#bold
Set
don't want duplicates in collection
예 {{{ #(1 1 1 1 2 2 2) asSet.
a Set(1 2) </code>
Equality Method
새로운 object를 추가할때 equaluty 유지하기?
Hashing Method
Dictionary
Sorted Collection
collection 에서 어떤 특정 조건의 sorting
Array
colletion with fixed number of element 예
| a | a := Array new: 5. 1 to: a size do: [ :n | a at: n put: n ]. ^ a #(1 2 3 4 5)
ByteArray
homogenous(균일한) information을 저장할때 사용
Interval
sequence number in collection (1 to: 20) do: [:each | ...]
예
| collection oc | collection := 1 to: 20 by: 2. oc := OrderedCollection new. oc addAll: collection. ^ oc an OrderedCollection(1 3 5 7 9 11 13 15 17 19)
collection.txt · Last modified: 2018/07/18 14:10 by 127.0.0.1