;===============================================================================
;
;			   C O L L E C T I O N S
;
;===============================================================================
[{AbstractClass} new 'name 'MetaCollection
	'superClass		{Class}
        'methods		'(
new ( elements                                   
      ;; --------------------------------------------------------------
      ;; Answer a new collection that contains all the objects of 
      ;; <elements> if this list is provided else answer an empty
      ;; collection.
      ;; --------------------------------------------------------------
      )
)]
 
[{AbstractClass} new 'name 'Collection
	'superClass 		{Object}
        'methods		'(
isEmpty (()	
         ;; ----------------------------------------------------------
         ;; Answer something true if the receiver is empty else answer
         ;; nil.
         ;; ----------------------------------------------------------
		(equal [self size] 0))

do ((aLambda)
    ;; --------------------------------------------------------------
    ;; For each element in the receiver, evaluate aLambda with that
    ;; element as its argument.
    ;; Answer the receiver.
    ;; --------------------------------------------------------------
	)

size (()
      ;; --------------------------------------------------------------
      ;; Answer the number of elements of the receiver.
      ;; --------------------------------------------------------------
	)
)]
 
[{Class} new 'name 'MetaDictionary
	'superClass		{MetaCollection}
        'methods		'(
new ( elements
       ;; --------------------------------------------------------------
       ;; Notice here that elements must be a list like:
       ;;	((key1 . value1) ... (keyN . valueN))
       ;; --------------------------------------------------------------
       	(let ( (newDictionary [super new 'aSymbol [{symbol} new]]) )
             (mapc '(lambda (pair)
                            [newDictionary at (car pair) (cdr pair)])
                   (car elements))
             newDictionary))
)]
	
[{MetaDictionary} new 'name 'Dictionary
	'superClass		{Collection}
        'instanceVariables	'(aSymbol)
        'methods		'(
at ((key . value)
	(if value
            (putprop #IaSymbol (car value) key)
            ;;ELSE
            (getprop #IaSymbol key)))

do ((aLambda)
	(let ( (pl (plist #IaSymbol)) )
             (while pl
                    (funcall aLambda (nextl pl) (nextl pl))))
        self)

size (()	(/ (length (plist #IaSymbol)) 2))
)]
	 
