" In one of our applications we needed the abilities of a Dictionary,
  with the organization of an OrderedCollection.  We combined the
  two classes into the new class, OrderedDictionary.

    To install this class, select the text below and then use the
    install ability.

   Written by: Paul Regenhardt - Simulation Sciences Inc. Denver, CO  "



Dictionary subclass: #OrderedDictionary
  instanceVariableNames: 
    'listKey '
  classVariableNames: ''
  poolDictionaries: '' !

!OrderedDictionary class methods ! !


!OrderedDictionary methods !

at: aKey put: anObject

     super at: aKey put: anObject.
     self listKey: aKey.!

atIndexKey: anInteger

      "Return the key at the given index."

     ^listKey at: anInteger.!

keys

       "Return the list keys."

    ^ listKey!

keysDo: aBlock
        "Answer the receiver.  For each key
         in the receiver, evaluate aBlock with
         the key as the argument."
    (self keys) do: [ :aKey |
        aBlock value: aKey]!

listKey
   "Answer the value of listKey."
   ^listKey!

listKey: aKey

        "Set the value of listKey."

    listKey = nil ifTrue: [listKey := OrderedCollection new].

    listKey add: aKey!

removeKey: aKey
        "Remove the key."

    super removeKey: aKey ifAbsent: [self errorAbsentKey].
    listKey removeIndex: (listKey indexOf: aKey)! !
