home *** CD-ROM | disk | FTP | other *** search
/ Really Useful CD 1 / ReallyUsefulCD1.iso / extras / languages / smalltalk / _smalltalk / prelude / set < prev    next >
Encoding:
Text File  |  1987-12-30  |  534 b   |  26 lines

  1. Class Set :Collection
  2. | list |
  3. [
  4.         new
  5.                 list <- List new
  6.  
  7. |       add: newElement
  8.           (list includes: newElement)
  9.                ifFalse: [list add: newElement]
  10.  
  11. |       remove: oldElement ifAbsent: exceptionBlock
  12.           list remove: oldElement ifAbsent: exceptionBlock
  13.  
  14. |       size
  15.                 ^ list size
  16.  
  17. |       occurrencesOf: anElement
  18.                 ^ (list includes: anElement) ifTrue: [1] ifFalse: [0]
  19.  
  20. |       first
  21.                 ^ list first
  22.  
  23. |       next
  24.                 ^ list next
  25. ]
  26.