Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- displayWithDisplayOrder: anArray in: aCollection
- | dictKeyIndex keys printedKeys currentKey index aBoolean |
- dictKeyIndex := Dictionary new.
- 1 to: anArray size do: [ :cpt | dictKeyIndex at: (anArray at: cpt) key put: cpt ].
- keys := dictKeyIndex keys.
- currentKey := displayOrder at: (index := 1).
- aBoolean := displayOrder includes: #*.
- aBoolean
- ifFalse: [ keys do: [ :each | aCollection addAll: (anArray at: (dictKeyIndex at: each)) value ] ]
- ifTrue: [
- "Before the * wildcard"
- [ currentKey ~= '*' ]
- whileTrue: [
- (keys includes: currentKey)
- ifTrue: [
- aCollection addAll: (anArray at: (dictKeyIndex at: currentKey)) value.
- keys remove: currentKey ].
- currentKey := displayOrder at: (index := index + 1) ].
- "The * wildcard"
- printedKeys := OrderedCollection new.
- keys
- do: [ :each |
- (displayOrder includes: each)
- ifFalse: [
- aCollection addAll: (anArray at: (dictKeyIndex at: each)) value.
- printedKeys add: each ] ].
- keys := keys select: [ :each | (printedKeys includes: each) not ].
- "After the * wildcard"
- index := index + 1.
- [ index > displayOrder size ]
- whileFalse: [
- currentKey := displayOrder at: index.
- (keys includes: currentKey)
- ifTrue: [ aCollection addAll: (anArray at: (dictKeyIndex at: currentKey)) value ].
- index := index + 1 ] ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement