      *>----------------------------------------------------------------
      *> A Dictionary stores key/data pairs or associations.
      *> Send the message "ofAssociations" to create a dictionary which
      *> stores instances of Association. Send the message "ofValues"
      *> to create a dictionary which stores key/data pairs.
      *>
      *>#See the section Using Dictionaries.
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd.
      *>
      *>----------------------------------------------------------------
      $set localcount(150) linkcount(200) mfoo
       class-id. dictionary data is protected
               inherits from ValueSet with data.


        object section.
        class-control.
           ValueSet is class "valueset"
           dictionary is class "dictinry"
           association is class "associtn"
           orderedcollection is class "ordrdcll"
           callback is class "callback".

       class-object.

       object-storage section.

      *>----------------------------------------------------------------
      *> Class method "withAll" reports an error as it is not always the
      *> case that there is enough information stored in aCollection to
      *> create a Dictionary.
      *>----------------------------------------------------------------
       method-id. "withAll".
       linkage section.
       01 anewcollection       usage object reference.
       01 acollection          usage object reference.

       procedure division using acollection
                          returning anewcollection.
           invoke self "shouldNotImplement" returning anewcollection
           exit method.
       end method "withAll".
      *>---------------------------------------------------------------
      *> PRIVATE. Method to create a dictionary of any type.
      *>---------------------------------------------------------------
       method-id. "privatenew".
       local-storage section.

       01 exceptionnumber  pic s9(9) comp-5.
       01 newsize          pic s9(9) comp-5.
       01 lsTemp           pic s9(9) comp-5.

       linkage section.
       01 lnksize              pic s9(9) comp-5.
       01 lnkstride             pic s9(9) comp-5.
       01 assoctemplate        usage object reference.
       01 acollection          usage object reference.
       01 lnktemplate          usage object reference.

       procedure division using lnksize lnktemplate
                                       lnkstride assoctemplate
                             returning acollection.

            invoke super "new" returning aCollection
            invoke acollection "initialize" using lnksize
                                                     lnktemplate
                                                     lnkstride
                                                     assoctemplate
            exit method.
       end method "privatenew".

      *>----------------------------------------------------------------
      *> Returns a new instance of Dictionary capable of holding a
      *> number of associations indicated by lnkSize. The class of
      *> Associations to be stored is indicated by assocTemplate. This
      *> method differs from "ofAssociations" as it causes the
      *> dictionary to store actual key/data pairs instead of instances
      *> of assocTemplate.
      *>
      *>#See class "associtn".
      *>
      *>----------------------------------------------------------------
       method-id. "ofValues".
       local-storage section.

       01 astride              pic s9(9) comp-5.
       01 lssize               pic s9(9) comp-5.

       linkage section.
       01 lnksize              pic s9(9) comp-5.
       01 assoctemplate        usage object reference.
       01 adictionary               usage object reference.

       procedure division using assoctemplate lnksize
                      returning adictionary.
           if lnksize < zero
               invoke self "invalidParameter" returning adictionary
           else
               if lnksize = zero
                   move 1 to lssize
               else
                   move lnksize to lssize
               end-if
               invoke assoctemplate "sizeInBytes" returning astride
               invoke self "privateNew" using lssize
                                               assoctemplate
                                               astride
                                               assoctemplate
                                     returning adictionary
           end-if
           exit method.
       end method "ofValues".
      *>----------------------------------------------------------------
      *> Return a new instance of Dictionary capable of holding a number
      *> of associations indicated by lnkSize. The class of Associations
      *> to be stored is indicated by assocTemplate. This new dictionary
      *> will actually store instances of assocTemplate.
      *>
      *>#See class "associtn".
      *>----------------------------------------------------------------
       method-id. "ofAssociations".
       local-storage section.

       01 astride              pic s9(9) comp-5.
       01 anObject             usage object reference.
       01 lssize               pic s9(9) comp-5.
       linkage section.
       01 lnksize              pic s9(9) comp-5.
       01 assoctemplate        usage object reference.
       01 adictionary               usage object reference.

       procedure division using assoctemplate lnksize
                      returning adictionary.
           if lnksize < zero
               invoke self "invalidParameter" returning adictionary
           else
               if lnksize = zero
                   move 1 to lssize
               else
                   move lnksize to lssize
               end-if
               move objectReferenceSize to aStride
               set anObject to null
               invoke self "privateNew" using lssize anObject
                                               astride assoctemplate
                                         returning adictionary
           end-if
           exit method.
       end method "ofAssociations".
      *>----------------------------------------------------------------
      *> Raise an exception as the message ofReferences is not
      *> appropriate for Dictionaries.
      *>----------------------------------------------------------------
       method-id. "ofReferences".
       linkage section.
       01 lnksize              pic s9(9) comp-5.
       01 adictionary               usage object reference.

       procedure division using lnksize returning adictionary.
           invoke self "shouldNotImplement" returning adictionary
           exit method.
       end method "ofReferences".

      *>----------------------------------------------------------------
      *> Returns a new instance of Dictionary capable of holding a
      *> number of associations indicated by lnkSize. The class of
      *> Associations to be stored is indicated by keyTemplate and
      *> collectiontemplate This method differs from "ofValues" as it creates
      *> the association template for you.
      *>----------------------------------------------------------------
       method-id. "ofValuesAuto".
       local-storage section.
       01 assoctemplate               usage object reference.

       linkage section.
       01 lnksize              pic s9(9) comp-5.
       01 keytemplate               usage object reference.
       01 collectiontemplate               usage object reference.
       01 adictionary               usage object reference.

       procedure division using keytemplate collectiontemplate lnksize
                      returning adictionary.
           invoke association "newclass" using
                             keytemplate
                             collectiontemplate
                             returning assoctemplate
           invoke self "ofValues" using assoctemplate lnksize
                      returning adictionary.
           exit method.
       end method "ofValuesAuto".
      *>----------------------------------------------------------------
      *> Return a new instance of Dictionary capable of holding a
      *> number of associations indicated by lnkSize. The class of
      *> Associations to be stored is indicated by keyTemplate and
      *> collectiontemplate This method differs from "ofAssociations" as
      *> it creates the association template for you.
      *>----------------------------------------------------------------
       method-id. "ofAssociationsAuto".
       local-storage section.
       01 assoctemplate               usage object reference.

       linkage section.
       01 lnksize              pic s9(9) comp-5.
       01 keytemplate               usage object reference.
       01 collectiontemplate               usage object reference.
       01 adictionary               usage object reference.

       procedure division using keytemplate collectiontemplate lnksize
                      returning adictionary.
           invoke association "newclass" using
                             keytemplate
                             collectiontemplate
                             returning assoctemplate
           invoke self "ofAssociations" using assoctemplate lnksize
                      returning adictionary.
           exit method.
       end method "ofAssociationsAuto".
       end class-object.

       Object.

       object-storage section.

          01 keyStatus          pic x comp-5.
                88 keyHasObjects        value 1.

          01 DataStatus          pic x comp-5.
                88 DataHasObjects        value 1.

      *>>---------------------------------------------------------------
      *>> Determines the type of keys stored within this dictionary. If
      *>> this holds the value NULL then real objects are being stored
      *>> as keys.
      *>>---------------------------------------------------------------

           01 keytemplate          usage object reference value null.

      *>>---------------------------------------------------------------
      *>> Determines the type of Associations stored within this
      *>> dictionary. If this holds the value NULL then real objects are
      *>> being stored as keys.
      *>>---------------------------------------------------------------

           01 associationtemplate  usage object reference value null.

      *>>---------------------------------------------------------------
      *>> Holds the size of the keys being stored
      *>>---------------------------------------------------------------
           01 keysize              pic x(4) comp-5 value 0.

       01 KEYITEM is typedef.
           03 abyte  pic x(objectreferencesize).
                           

      *>>---------------------------------------------------------------
      *>> Holds the size of the data being stored
      *>>---------------------------------------------------------------
           01 datasize             pic x(4) comp-5 value 0.

       01 DATAITEM is typedef.
           03 abyte  pic x(objectreferencesize).
                           

      *>>---------------------------------------------------------------
      *>> Determines the class of Associations stored within this
      *>> dictionary. This is needed in addition to the association
      *>> template as the template may be NULL but this does not mean
      *>> the dictionary is storing default Associations.
      *>>---------------------------------------------------------------
           01 associationclass     usage object reference value null.
      *>---------------------------------------------------------------
      *> PRIVATE. method used to initialize instance variables of new
      *> dictionaries.
      *>---------------------------------------------------------------
       method-id. "initialize".
       linkage section.
       01 lnktemplate          usage object reference.
       01 lnksize              pic s9(9) comp-5.
       01 lnkassoctemplate        usage object reference.
       01 lnkstride             pic s9(9) comp-5.

       procedure division using lnksize lnktemplate
                                lnkstride lnkassoctemplate.
           invoke super "initialize" using lnksize lnktemplate
                                                lnkstride
           set associationtemplate to lnktemplate
           set associationclass to lnkassoctemplate
           invoke lnkassoctemplate "getKeyTemplate"
                               returning keytemplate
           invoke lnkassoctemplate "getdatatemplate"
                               returning collectiontemplate
           invoke keytemplate "sizeInBytes" returning keysize
           invoke collectiontemplate "sizeInBytes" returning datasize
      $if gc defined
           invoke keyTemplate "storingobjects" returning keyStatus
           invoke collectiontemplate "storingobjects"
                                returning dataStatus
      $end
           exit method.
       end method "initialize".

      *>----------------------------------------------------------------
      *> PRIVATE. CallBack used to implement displaykeysAndData
      *>----------------------------------------------------------------
       method-id. "displayObjectKVBM".
       linkage section.
       01 lnkIndex             KEYITEM.
       01 anelement            COLLECTABLE.

       procedure division using lnkIndex anelement.
           if keyTemplate = null
                  invoke lnkIndex as object "display"
           else
                  invoke lnkIndex as keyTemplate "display"
           end-if
           display "->" with no advancing
           invoke anelement as object "display"
           display " " with no advancing
           exit method.
       end method "displayObjectKVBM".
      *>----------------------------------------------------------------
      *> PRIVATE. CallBack used to implement displaykeysAndData
      *>----------------------------------------------------------------
       method-id. "displayIntrinsicKVBM".
       linkage section.
       01 lnkIndex             KEYITEM.
       01 anelement            COLLECTABLE.

       procedure division using lnkIndex anelement.
           if keyTemplate = null
                  invoke lnkIndex as object "display"
           else
                  invoke lnkIndex as keyTemplate "display"
           end-if
           display "->" with no advancing
           invoke anelement as collectiontemplate "display"
           display " " with no advancing
           exit method.
       end method "displayIntrinsicKVBM".
      *>---------------------------------------------------------------
      *> Returns a new Dictionary which is capable of storing the same
      *> types of key and data but has the capability of storing lnkSize
      *> of them.
      *>---------------------------------------------------------------
       method-id. "copyEmptyWithSize".
       local-storage section.

       01 aclass           usage object reference.
       01 astride              pic s9(9) comp-5.

       linkage section.
       01 anewcollection       usage object reference.
       01 lnksize              pic s9(9) comp-5.

       procedure division using lnksize
                                       returning anewcollection.
           invoke self "species" returning aclass
           invoke associationtemplate "sizeInBytes" returning astride
           invoke aclass "privateNew" using lnksize
                                               associationtemplate
                                               astride
                                               associationclass
                                    returning anewcollection
           exit method.
       end method "copyEmptyWithSize".
      *>---------------------------------------------------------------
      *> PRIVATE. Returns true if the association (anELement) is at a
      *> real integer index (anIndex)
      *>---------------------------------------------------------------
       method-id. "isat".
       local-storage section.
       01 lsBuffer         pic x(bufferSize).
       01 aptr             pointer.

       linkage section.
       01 anindex              pic s9(9) comp-5.
       01 anelement2           COLLECTABLE.
       01 anelement            COLLECTABLE.
       01 lnkbool                 pic x comp-5.
           88 lnkistrue           value 1.
           88 lnkisfalse          value 0.

       procedure division using anelement anindex
                          returning lnkbool.
           invoke self "isOccuppiedAt" using anindex
                                        returning lnkbool
           if lnkistrue
               if collectionStride > bufferSize
                   invoke self "allocateElement" returning aptr
                   set address of anelement2 to aptr
               else
                   move low-values to lsBuffer
                   set address of anElement2 to address of lsBuffer
               end-if
               invoke self "basicatNoGC" using anindex
                        returning anElement2
               if associationtemplate equal to null
                   invoke anelement2 as object "equal" using anelement
                                  returning lnkbool

               else
                   invoke anelement as associationtemplate
                       "equalbyLengthValue" using collectionstride
                                                  anelement2
                                        returning lnkbool

               end-if
               if collectionStride > bufferSize
                   invoke self "dealloc" using aptr
               end-if
           end-if
           exit method.
       end method "isat".
      *>---------------------------------------------------------------
      *> Returns the association at aKey. Raise an exception if the
      *> dictionary does not contain aKey.
      *>
      *>#See method "includesKey".
      *>---------------------------------------------------------------
       method-id. "associationAt".
       local-storage section.

       01 i                pic s9(9) comp-5.
       01 exceptionnumber  pic s9(9) comp-5.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.
       01 lselement            object reference.

       linkage section.
       01 akey                 KEYITEM.
       01 anelement            COLLECTABLE.

       procedure division using akey returning anelement.
           invoke self "findKey" using akey bool returning i
           if istrue
               if associationtemplate = null
                   invoke self "privateat" using i returning lselement
                   invoke lselement "copy" returning anelement
               else
                   invoke self "privateat" using i returning anelement
               end-if
           else
               move 12 to exceptionnumber
               invoke self "raiseException" using exceptionnumber
                                             returning anelement
           end-if
           exit method.
       end method "associationAt".

      *>---------------------------------------------------------------
      *> Returns the data at aKey. Raise an exception if the
      *> dictionary does not contain aKey.
      *>
      *>#See method "includesKey".
      *>---------------------------------------------------------------
       method-id. "at".
       local-storage section.
       01 exceptionnumber  pic s9(9) comp-5.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.
       01 i                pic s9(9) comp-5.

       linkage section.
       01 anelement             COLLECTABLE.
       01 akey                  KEYITEM.
       01 lnkdata               DATAITEM.

       procedure division using akey returning lnkdata.
           invoke self "findKey" using akey bool returning i
           if istrue
               invoke self "basicDataAt" using i returning lnkData
           else
               move 12 to exceptionnumber
               invoke self "raiseException" using exceptionnumber
                                             returning lnkdata
           end-if
           exit method.
       end method "at".

      *>---------------------------------------------------------------
      *> Return the data at aKey. If this dictionary does not
      *> contain aKey then NULL is returned. If NULL is actually stored
      *> at aKey then NULL will be returned also.
      *>
      *>#See method "includesKey".
      *>---------------------------------------------------------------
       method-id. "atOrNil".
       local-storage section.
       01 i                pic s9(9) comp-5.
       01 lsptr                pointer.
       01 lsBuffer             pic x(BUFFERSIZE).
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 akey                 KEYITEM.
       01 lnkdata              DATAITEM.
       01 lnkdata2             DATAITEM.

       procedure division using akey returning lnkdata.
           invoke self "findKey" using akey bool returning i
           if istrue
               invoke self "basicDataAt" using i returning lnkData
           else
      $if gc defined
               if collectiontemplate = null
                   call "oopsassignobjectreference"
                          using by reference lnkData(1:datasize)
                                by value 0
               else
                   if dataHasObjects
                        if datasize <= BUFFERSIZE
                            move low-values to lsBuffer
                            invoke lsBuffer(1:datasize)
                                AS collectiontemplate
                                "getValue"
                                returning lnkdata(1:datasize)
                        else
                            invoke self "allocateElement"
                                returning lsptr
                            set address of lnkData2 to lsPtr
                            invoke lnkData2(1:datasize) AS
                                collectiontemplate
                                "getValue"
                                returning lnkdata(1:datasize)
                            invoke self "dealloc" using lsPtr
                        end-if
                   else
                        move low-values to lnkdata(1:datasize)
                   end-if
               end-if
      $else
               move low-values to lnkdata(1:datasize)
      $end
           end-if
           exit method.
       end method "atOrNil".
      *>---------------------------------------------------------------
      *> Return the key at the first occurrence of lnkData. Raise an
      *> exception if the dictionary does not contain lnkData.
      *>
      *>#See method "includes".
      *>---------------------------------------------------------------
       method-id. "keyAtData".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 exceptionnumber      pic s9(9) comp-5.
       01 dataPtr              usage pointer.
       01 keyPtr               usage pointer.
       01 nthParm              pic x(4) comp-5.
       01 4bytebool            pic x(4) comp-5.
       01 bool                 pic x comp-5.
               88 istrue     value 1.
               88 isfalse    value 0.
       01 lsptr                 pointer.
       01 lsBuffer         pic x(bufferSize).

       linkage section.
       01 akey                  KEYITEM.
       01 lnkdata               DATAITEM.
       01 lnkkey2               KEYITEM.

       procedure division using lnkdata returning akey.
      $if gc defined
           if keytemplate = null
                call "oopsassignobjectreference"
                        using by reference akey(1:keysize)
                              by value 0
           else
                if keyhasobjects
                    if keysize <= buffersize
                        move low-values to lsBuffer
                        invoke lsBuffer(1:keysize) as keytemplate
                                "getValue" returning akey(1:keysize)
                    else
                        invoke self "allocateElement" returning lsPtr
                        set address of lnkKey2 to lsPtr
                        invoke lnkKey2(1:keysize) as keytemplate
                            "getValue" returning
                            akey(1:keysize)
                                
                        invoke self "dealloc" using lsPtr
                    end-if
                else
                    move low-values to akey(1:keysize)
                end-if
           end-if
      $else
           move low-values to akey(1:keysize)
      $end
           move "keyAtDataBM" to amessageselector
           set dataPtr to address of lnkData
           set keyPtr  to address of aKey
           invoke callback "new" using self amessageselector
                                       4bytebool dataPtr keyPtr
                             returning amessage2
           invoke self "keysAndDataDo" using amessage2
           move 1 to nthParm
           invoke amessage2 "getParameter" using nthParm
                                       returning 4bytebool
           move 4bytebool to bool
           if isfalse
               move 12 to exceptionnumber
               invoke self "raiseException" using exceptionnumber
                                        returning akey
           end-if
           invoke amessage2 "finalize" returning amessage2
           exit method.
       end method "keyAtData".
      *>---------------------------------------------------------------
      *> PRIVATE. CallBack used to implement keyAtData.
      *>---------------------------------------------------------------
       method-id. "keyAtDataBM".
       local-storage section.
       01 bool              pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 akey                  KEYITEM.
       01 lnkdata               DATAITEM.
       01 akey2                 KEYITEM.
       01 lnkdata2              DATAITEM.
       01 lnkdataPtr            usage pointer.
       01 lnkkeyPtr             usage pointer.
       01 lnkbool              pic x(4) comp-5.
       procedure division using lnkbool lnkdataptr lnkkeyptr
                                           akey2 lnkdata2.
           set address of lnkData to lnkDataPtr
           set address of aKey to lnkKeyPtr
           if collectiontemplate equal to null
               invoke lnkdata2 as object "equal" using lnkdata
                                   returning bool
           else
               invoke lnkdata2 as collectiontemplate
                   "equalbyLengthValue" using datasize lnkdata
                                    returning bool
           end-if
           if istrue
      $if gc defined
               if keytemplate = null
                   call "oopsassignobjectreference"
                          using by reference
                                    akey(1:objectreferencesize)
                                by value
                                    akey2(1:objectreferencesize)
               else
                   if keyhasobjects
                        invoke akey2(1:keysize) as keytemplate
                                "getvalue" returning akey(1:keysize)

                   else
                        move akey2(1:keysize) to akey(1:keysize)
                   end-if
               end-if
      $else
               move akey2(1:keysize) to akey(1:keysize)
      $end
               
               move bool to ooiteratorflag
           end-if
           move bool to lnkbool
           exit method.
       end method "keyAtDataBM".

      *>---------------------------------------------------------------
      *> Return the key at the first occurrence of lnkData. Raise an
      *> exception if the dictionary does not contain lnkData.
      *> Comparison of data values is done by identity.
      *>---------------------------------------------------------------
       method-id. "keyAtDataByIdentity".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 exceptionnumber      pic s9(9) comp-5.
       01 dataPtr              usage pointer.
       01 keyPtr               usage pointer.
       01 nthParm              pic x(4) comp-5.
       01 4bytebool            pic x(4) comp-5.
       01 bool                 pic x comp-5.
               88 istrue     value 1.
               88 isfalse    value 0.
       01 lsptr                 pointer.
       01 lsBuffer         pic x(bufferSize).
       linkage section.
       01 akey                  KEYITEM.
       01 lnkKey2               KEYITEM.
       01 lnkdata               DATAITEM.

       procedure division using lnkdata returning akey.
      $if gc defined
           if keytemplate = null
                call "oopsassignobjectreference"
                        using by reference akey(1:keysize)
                              by value 0
           else
                if keyhasobjects
                    if keysize <= buffersize
                        move low-values to lsbuffer
                        invoke lsBuffer(1:keysize) as keytemplate
                                "getvalue" returning akey(1:keysize)
                    else
                        invoke self "allocateElement" returning lsPtr
                        set address of lnkKey2 to lsPtr
                        invoke lnkKey2 (1:keysize) as keytemplate 
                                "getvalue" returning akey(1:keysize)
                        invoke self "dealloc" using lsptr
                    end-if
                else
                    move low-values to akey(1:keysize)
                end-if
           end-if
      $else
           move low-values to akey(1:keysize)
      $end

           move "keyAtDataBMIdentity" to amessageselector
           set dataPtr to address of lnkData
           set keyPtr  to address of aKey
           invoke callback "new" using self amessageselector
                                       4bytebool dataPtr keyPtr
                             returning amessage2
           invoke self "keysAndDataDo" using amessage2
           move 1 to nthParm
           invoke amessage2 "getParameter" using nthParm
                                       returning 4bytebool
           move 4bytebool to bool
           if isfalse
               move 12 to exceptionnumber
               invoke self "raiseException" using exceptionnumber
                                        returning akey
           end-if
           invoke amessage2 "finalize" returning amessage2
           exit method.
       end method "keyAtDataByIdentity".
      *>---------------------------------------------------------------
      *> PRIVATE. CallBack used to implement keyAtDataByIdentity.
      *>---------------------------------------------------------------
       method-id. "keyAtDataBMIdentity".
       linkage section.
       01 akey                  KEYITEM.
       01 lnkdata               DATAITEM.
       01 akey2                 KEYITEM.
       01 lnkdata2              DATAITEM.
       01 lnkdataPtr            usage pointer.
       01 lnkkeyPtr             usage pointer.
       01 lnkbool               pic x(4) comp-5.
       procedure division using lnkbool lnkdataptr lnkkeyptr
                                           akey2 lnkdata2.
           set address of lnkData to lnkDataPtr
           set address of aKey to lnkKeyPtr
           if lnkdata(1:dataSize) = lnkData2(1:dataSize)        
               move 1 to lnkbool
      $if gc defined
               if keytemplate = null
                   call "oopsassignobjectreference"
                      using by reference akey(1:objectreferencesize)
                               by value akey2(1:objectreferencesize)
               else
                   if keyhasobjects
                        invoke akey2(1:keysize) as keytemplate
                                "getvalue" returning akey(1:keysize)
                   else
                        move akey2(1:keysize) to akey(1:keysize)
                   end-if
               end-if
      $else
               move akey2(1:keysize) to akey(1:keysize)
      $end
               move 1 to ooiteratorflag
           else
               move 0 to lnkbool
           end-if
           exit method.
       end method "keyAtDataBMIdentity".
      *>---------------------------------------------------------------
      *> Add the association (anElement) to this dictionary. If the
      *> dictionary already contains this association then it is not
      *> added.
      *>---------------------------------------------------------------
       method-id. "add".
       local-storage section.

       01 realindex        pic s9(9) comp-5.
       01 i                pic s9(9) comp-5.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.
       01 growthLimit         pic x(4) comp-5.
       01 lsObject            usage object reference.

      $if GC not defined
       01 lsPIcx              pic x(4) redefines lsObject.
      $end
       linkage section.
       01 anelement           COLLECTABLE.
       01 instanceData        pic x.
       procedure division using anelement.
           multiply capacity by 7 giving growthLimit
           divide 10 into growthLimit
           if growthLimit <= numberelements
               invoke self "grow"
           end-if
           invoke self "findELement" using anelement returning i
           invoke self "isEmptyAt" using i returning bool
           if istrue
               compute realindex = (i - 1) * collectionstride + 1
               set address of instanceData to collptr
               if associationTemplate = null
      $if GC defined
                   call "oopsassignobjectreference" using
                     by reference
                            instancedata(realindex:objectreferencesize)
                     by value anElement(1:objectreferencesize)
      $else  
                   invoke anElement as object "copy"
                           returning lsObject
                   move lsPicX(1:objectreferencesize) to
                    instancedata(realindex:objectreferencesize)
      $end
               else
      $if GC defined
                   if storingObjects
                        invoke anelement(1:collectionStride)
                                as associationTemplate "getvalue"
                        returning
                                instancedata(realindex:collectionstride)
                   else
                        move anelement(1:collectionStride) to
                           instancedata(realindex:collectionstride)
                   end-if
      $else  
                   move anelement(1:collectionStride) to
                    instancedata(realindex:collectionstride)
      $end
               end-if
               invoke self "setOccuppied" using i
               add 1 to numberelements
           end-if
           exit method.
       end method "add".
      *>---------------------------------------------------------------
      *> Return anOrderedCollection of Associations which make up
      *> this dictionary.
      *>---------------------------------------------------------------
       method-id. "associations".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 asize                pic s9(9) comp-5.

       linkage section.
       01 anewcollection       usage object reference.

       procedure division returning anewcollection.
           invoke self "size" returning asize
           invoke orderedcollection "ofValues"
                        using associationtemplate asize
                        returning anewcollection
           move "add" to amessageselector
           invoke callback "new" using anewcollection amessageselector
                                     returning amessage2
           invoke self "associationsDoWithOutCopy" using amessage2
           invoke amessage2 "finalize" returning aMessage2
           exit method.
       end method "associations".
      *>---------------------------------------------------------------
      *> Return a ValueSet of the keys which this dictionary contains.
      *>
      *>#See class "valueset".
      *>---------------------------------------------------------------
       method-id. "keys".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 asize                pic s9(9) comp-5.

       linkage section.
       01 anewcollection       usage object reference.

       procedure division returning anewcollection.
           invoke self "size" returning asize
           invoke ValueSet "ofValues" using keytemplate asize
                   returning anewcollection
           move "add" to amessageselector
           invoke callback "new" using anewcollection amessageselector
                                     returning amessage2
           invoke self "keysDo" using amessage2
           invoke amessage2 "finalize" returning aMessage2
           exit method.
       end method "keys".
      *>---------------------------------------------------------------
      *> Return an OrderedCollection of the data values which are
      *> stored within this collection.
      *>
      *>#See class "ordrdcll".
      *>---------------------------------------------------------------
       method-id. "data".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 asize                pic s9(9) comp-5.

       linkage section.
       01 anewcollection       usage object reference.

       procedure division returning anewcollection.
           invoke self "size" returning asize
           invoke orderedcollection "ofValues"
                        using collectiontemplate asize
                        returning anewcollection
           move "add" to amessageselector
           invoke callback "new" using anewcollection amessageselector
                                     returning amessage2
           invoke self "do" using amessage2
           invoke amessage2 "finalize" returning aMessage2
           exit method.
       end method "data".
      *>---------------------------------------------------------------
      *> Return the number of times lnkData occurs within this
      *> dictionary.
      *>---------------------------------------------------------------
       method-id. "occurrencesOf".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 dataPtr              usage pointer.

       linkage section.
       01 lnkdata               DATAITEM.
       01 anumber              pic s9(9) comp-5.
       procedure division using lnkdata returning anumber.
           move "occurrencesOfBM" to amessageselector
           move zero to anumber
           set dataPtr to address of lnkData
           invoke callback "new" using self amessageselector
                                       anumber dataPtr
                                     returning amessage2
           invoke self "do" using amessage2
           move 1 to anumber
           invoke amessage2 "getParameter" using anumber
                                       returning anumber
           invoke amessage2 "finalize" returning aMessage2
           exit method.
       end method "occurrencesOf".
      *>---------------------------------------------------------------
      *> PRIVATE. CallBack used to implement occurrencesOf.
      *>---------------------------------------------------------------
       method-id. "occurrencesOfBM".
       local-storage section.

       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 lnkdata               DATAITEM.
       01 lnkcount              pic s9(9) comp-5.
       01 lnkdata2              DATAITEM.
       01 lnkDataPtr            usage pointer.

       procedure division using lnkcount lnkDataPtr lnkdata2.
           set address of lnkData to lnkDataPtr
           if collectiontemplate equal to null
               invoke lnkdata2 as object "equal" using lnkdata
                                   returning bool
           else
               invoke lnkdata2 as collectiontemplate
                       "equalbyLengthValue"
                                        using datasize lnkdata
                                    returning bool
           end-if
           if istrue
               add 1 to lnkcount
           end-if
           exit method.
       end method "occurrencesOfBM".
      *>----------------------------------------------------------------
      *> Returns true (1) if this Dictionary contains anElement
      *> otherwise returns false (0).
      *>----------------------------------------------------------------
       method-id. "includes".
       local-storage section.

       01 amessageselector         pic x(80).
       01 amessage2                usage object reference.
       01 dataPtr                  usage pointer.
       01 nthParm                   pic x(4) comp-5.
       01 4bytebool                   pic x(4) comp-5.

       linkage section.
       01 lnkdata                 DATAITEM.
       01 lnkbool                 pic x comp-5.
           88 lnkistrue           value 1.
           88 lnkisfalse          value 0.

       procedure division using lnkdata returning lnkbool.
           move "includesBM" to amessageselector
           set dataPtr to address of lnkData
           invoke callback "new" using self amessageselector
                                       4bytebool dataPtr
                             returning amessage2
           invoke self "do" using amessage2
           move 1 to nthParm
           invoke amessage2 "getParameter" using nthParm
                                       returning 4bytebool
           move 4bytebool to lnkbool
           invoke amessage2 "finalize" returning aMessage2
           exit method.
       end method "includes".
      *>---------------------------------------------------------------
      *> PRIVATE. CallBack used to implement "includes".
      *>---------------------------------------------------------------
       method-id. "includesBM".
       local-storage section.
       01 abool                pic x comp-5.
       linkage section.
       01 lnkdata              DATAITEM.
       01 lnkdata2             DATAITEM.
       01 bool                 pic x(4) comp-5.
           88 lnkistrue           value 1.
           88 lnkisfalse          value 0.
       01 lnkDataPtr               usage pointer.

       procedure division using bool lnkdataPtr lnkdata2.
           set address of lnkData to lnkDataPtr
           if collectiontemplate equal to null
               invoke lnkdata2 as object "equal" using lnkdata
                                   returning abool
           else
               invoke lnkdata2 as collectiontemplate
                               "equalbyLengthValue"
                                       using datasize lnkdata
                                   returning abool
           end-if
           move abool to ooiteratorflag bool
           exit method.
       end method "includesBM".
      *>---------------------------------------------------------------
      *> PRIVATE. Returns the real index of the association anElement.
      *>---------------------------------------------------------------
       method-id. "findElement".
       local-storage section.

       01 temp                pic s9(9) comp-5.
       01 hashvalue           pic s9(9) comp-5.
       01 asize               pic s9(9) comp-5.
       01 bool                pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 anindex              pic s9(9) comp-5.
       01 anelement            COLLECTABLE.

       procedure division using anelement returning anindex.
           move capacity to asize
           if associationtemplate equal to null
               invoke anelement as object "hash" returning hashvalue
           else
               invoke anelement as associationtemplate "hash"
                                        returning hashvalue
           end-if
           move hashvalue to anindex
           set isfalse to true
           perform with test after until istrue
               divide anindex by asize giving temp
                                      remainder anindex
               add 1 to anindex
               invoke self "isEmptyAt" using anindex returning bool
               if isfalse
                   invoke self "isAt" using anelement anindex
                                   returning bool
               end-if
           end-perform
           exit method.
       end method "findElement".

      *>---------------------------------------------------------------
      *> PRIVATE. Returns the real index of the key aKey.
      *>---------------------------------------------------------------
       method-id. "findKey".
       local-storage section.
       01 lsBuffer             pic x(bufferSize).
       01 temp                 pic s9(9) comp-5.
       01 asize                pic s9(9) comp-5.
       01 aptr                 pointer.
       01 aptr2                pointer.
       01 hashvalue            pic s9(9) comp-5.
       01 bool                 pic x comp-5.
          88 istrue       value 1.
          88 isfalse      value 0.
       01 emptystatus          pic x comp-5.
          88 isoccuppied  value 1.
          88 isempty      value 0.

       linkage section.
       01 lnkbool                 pic x comp-5.
           88 lnkistrue           value 1.
           88 lnkisfalse          value 0.
       01 anindex              pic s9(9) comp-5.
       01 akey                  KEYITEM.
       01 lnkKey                KEYITEM.

       procedure division using akey lnkbool returning anindex.
           move capacity to asize
           if keytemplate equal to null
               invoke akey as object "hash" returning hashvalue
           else
               invoke akey as keytemplate "hash" returning hashvalue
           end-if
           move hashvalue to anindex
           set isfalse to true
           set isoccuppied to true

           if keysize > bufferSize
               invoke self "malloc" using keysize returning aptr
               set address of lnkKey to aptr
           else
               move low-values to lsBuffer
               set address of lnkKey to address of lsBuffer
           end-if


           perform with test after until istrue
               divide anindex by asize giving temp
                                      remainder anindex
               add 1 to anindex
               invoke self "isEmptyAt" using anindex returning bool
               if isfalse
                   invoke self "basicKeyAt" using anindex
                                     returning lnkKey
                   if keytemplate equal to null
                       invoke lnkKey as object "equal" using akey
                                returning bool
                   else
                       invoke lnkKey as keytemplate "equalbyLengthValue"
                                             using keysize akey
                                         returning bool
                   end-if
               else
                   set isempty to true
               end-if
           end-perform
      $if gc defined
           if keytemplate = null
                call "oopsrelease" using by value 1
                                by value lnkKey(1:objectreferencesize)
           else
                if keyHasObjects
                        invoke lnkKey(1:keysize) as keytemplate
                                "decreaseReferences"
                end-if
           end-if
      $end
           if keysize > bufferSize
               invoke self "dealloc" using aptr
           end-if
           move emptystatus to lnkbool
           exit method.
       end method "findKey".
      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each association as a parameter.
      *> aMessage should be a CallBack pointing to a method which
      *> expects an association as a parameter.
      *>
      *>#See the section Iterating Collections.
      *>---------------------------------------------------------------
       method-id. "associationsDo".
       local-storage section.
       01 aNewCopy             usage object reference.
       01 ooreturnptr          usage pointer.
       01 bool                 pic x comp-5.
          88 istrue           value 1.
          88 isfalse          value 0.
       01 j                    pic s9(9) comp-5.
       01 i                    pic s9(9) comp-5.
       01 thissize             pic s9(9) comp-5.

       linkage section.
       01 anelement            COLLECTABLE.
       01 amessage             usage object reference.

       procedure division using amessage.
           invoke self "copy" returning aNewCopy
           invoke aNewCopy "size" returning thissize
           set oonoquit to true
           invoke self "allocateElement" returning ooreturnptr
           move zero to i
           set address of anelement to ooreturnPtr
           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke aNewCopy "isEmptyAt" using j returning bool
               if isfalse
                   invoke aNewCopy "basicAt" using j returning anElement
                   invoke amessage "invoke" using anElement
                   add 1 to i
               end-if
           end-perform
           set oonoquit to true
      $if gc defined
           if associationTemplate = null
                call "oopsrelease" using by value 1
                                anElement(1:collectionStride)
           else
                if Storingobjects
                        invoke anElement as associationTemplate
                                "decreaseReferences"
                end-if
           end-if
      $end

           invoke self "dealloc" using ooreturnptr
           invoke aNewCopy "finalize" returning aNewCopy
           exit method.
       end method "associationsDo".


      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each association as a parameter.
      *> aMessage should be a CallBack pointing to a method which
      *> expects an association as a parameter.
      *>
      *>#See the section Iterating Collections.
      *>---------------------------------------------------------------
       method-id. "associationsDoWithOutCopy".
       linkage section.
       01 amessage             usage object reference.

       procedure division using amessage.
           invoke super "doWithOutCopy"  using amessage
           exit method.
       end method "associationsDoWithOutCopy".
      *>----------------------------------------------------------------
      *> PRIVATE. Causes the whole contents of the receiver to be
      *> replaced with the contents of aCollection. The only use
      *> of this method is to perform rehashing after a grow.
      *>----------------------------------------------------------------
       method-id. "replaceContentsWith".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.

       linkage section.
       01 acollection          usage object reference.
       01 instanceData         pic x.
       procedure division using acollection.
           set address of instanceData to collptr
      $if GC defined
           if associationtemplate = null
                call "oopstablerelease"
                             using by value capacity
                                   by value collectionStride
                                   by reference instanceData(1:)
           else
                if keytemplate = null
                   call "oopstablerelease"
                                using by value capacity
                                      by value collectionStride
                                      by reference instanceData(1:)
                end-if
                if collectiontemplate = null
                   call "oopstablerelease"
                           using by value capacity
                                 by value collectionStride
                                 by reference instanceData(1 + keysize:)
                end-if
           end-if
      $end  
           move low-values to instancedata(1:
                                   storagerequirements + emptybits)
           move zero to numberelements
           move "add" to amessageselector
           invoke callback "new" using self amessageselector
                                    returning amessage2
           invoke acollection "associationsdoWithOutCopy"
                        using amessage2
           invoke amessage2 "finalize" returning aMessage2
           exit method.
       end method "replaceContentsWith".
      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each data item associated with the association as a
      *> parameter.
      *> aMessage should be a CallBack pointing to a method which
      *> expects a data item as a parameter.
      *>
      *>#See the section Iterating Collections.
      *>---------------------------------------------------------------
       method-id. "doWithOutCopy".
       local-storage section.

       01 ooreturnptr      usage pointer.
       01 i                pic s9(9) comp-5.
       01 j                pic s9(9) comp-5.
       01 k                pic s9(9) comp-5.
       01 thissize         pic s9(9) comp-5.
       01 aptr             pointer.
       01 memToAlloc       pic x(4) comp-5.
       01 bool             pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 lnkreturnbuffer       COLLECTABLE.
       01 lnkdata               DATAITEM.
       01 amessage              usage object reference.

       procedure division using amessage.
           invoke self "size" returning thissize
           set oonoquit to true
           move zero to i

           compute memToAlloc = collectionStride + dataSize
           invoke self "malloc" using memToAlloc returning ooReturnPtr

           set address of lnkreturnbuffer to ooreturnptr
           set aptr to ooReturnPtr
           set aptr up by collectionStride
           set address of lnkdata to aptr

           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke self "isEmptyAt" using j returning bool
               if isfalse
                   invoke self "basicDataAt" using j
                                returning lnkData
                   invoke amessage "invoke" using lnkdata
                                        returning lnkreturnbuffer
                   add 1 to i
               end-if
           end-perform
      $if gc defined
           if collectiontemplate = null
                call "oopsrelease" using by value 1
                    by value lnkData(1:objectreferencesize)
           else
                if dataHasObjects
                        invoke lnkData(1:datasize) as collectiontemplate
                                "decreaseReferences"
                        
                end-if

           end-if
      $end
           invoke self "dealloc" using ooreturnptr
           set oonoquit to true
           exit method.
       end method "doWithOutCopy".
      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each data item associated with the association as a
      *> parameter.
      *> aMessage should be a CallBack pointing to a method which
      *> expects a data item as a parameter.
      *>
      *>#See the section Iterating Collections.
      *>---------------------------------------------------------------
       method-id. "do".
       local-storage section.
       01 aCopy            usage object reference.
       01 ooreturnptr      usage pointer.
       01 i                pic s9(9) comp-5.
       01 j                pic s9(9) comp-5.
       01 k                pic s9(9) comp-5.
       01 thissize         pic s9(9) comp-5.
       01 aptr             pointer.
       01 memToAlloc       pic x(4) comp-5.
       01 bool             pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 lnkreturnbuffer      COLLECTABLE.
       01 lnkdata              DATAITEM.
       01 amessage             usage object reference.

       procedure division using amessage.
           invoke self "size" returning thissize
           set oonoquit to true
           move zero to i

           compute memToAlloc = collectionStride + dataSize
           invoke self "malloc" using memToAlloc returning ooReturnPtr

           set address of lnkreturnbuffer to ooreturnptr
           set aptr to ooReturnPtr
           set aptr up by collectionStride
           set address of lnkdata to aptr

           invoke self "copy" returning acopy
           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke acopy "isEmptyAt" using j returning bool
               if isfalse
                   invoke acopy "basicDataAt" using j returning lnkData
                   invoke amessage "invoke" using lnkdata
                                        returning lnkreturnbuffer
                   add 1 to i
               end-if
           end-perform

      $if gc defined
           if collectiontemplate = null
                call "oopsrelease" using by value 1
                         by value lnkData(1:objectreferencesize)
           else
                if dataHasObjects
                        invoke lnkData(1:datasize) as collectiontemplate
                                "decreaseReferences"
                        
                end-if

           end-if
      $end

           invoke acopy "finalize" returning acopy
           invoke self "dealloc" using ooreturnptr
           set oonoquit to true
           exit method.
       end method "do".

      $if gc not defined

      *>----------------------------------------------------------------
      *> Returns a shallow copy of the receiver.
      *>----------------------------------------------------------------
       method-id. "Copy".
       linkage section.
       01 result               usage object reference.

       procedure division returning result.
           invoke self "basicCopy" returning result
           exit method.
       end method "Copy".


      *>----------------------------------------------------------------
      *> Returns a shallow copy of the receiver.
      *>----------------------------------------------------------------
       method-id. "basicCopy".
       local-storage section.
       01 lsSize   pic x(4) comp-5.
       01 exceptionnumber      pic x(4) comp-5.
       01 aBM                  usage object reference.
       01 aMessage             pic x(80).

       linkage section.
       01 result               usage object reference.

       procedure division returning result.
           if associationtemplate = null
               move "basicCopyBM" to aMessage
               invoke self "capacity" returning lsSize
               invoke self "copyEmptyWithSize" using lsSize
                                       returning result
               invoke callback "new" using self  aMessage
                                       result
                             returning abm
               invoke self "AssociationsdoWithoutCopy" using abm
               invoke abm "finalize" returning abm
           else
               invoke super "copy" returning result
           end-if
           exit method.
       end method "basicCopy".
      *>----------------------------------------------------------------
      *> PRIVATE. Copy a member of this collection and add it to the new
      *> collection.
      *>----------------------------------------------------------------
       method-id. "basicCopyBM".
       local-storage section.
       01 anElement2           usage object reference.
       01 aKey2                usage object reference.
       01 aValue2              usage object reference.

       linkage section.
       01 lnkKey               usage object reference.
       01 lnkValue             usage object reference.
       01 anewcollection       usage object reference.
       01 anelement            usage object reference.

       procedure division using anewcollection anelement.
           invoke anewcollection "add" using anElement
           exit method.
       end method "basicCopyBM".
      $end

      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each key item associated with the association as a
      *> parameter.
      *> aMessage should be a CallBack pointing to a method which
      *> expects a key item as a parameter.
      *>
      *>#See the section Iterating Collections.
      *>---------------------------------------------------------------
       method-id. "keysdo".
       local-storage section.

       01 ooreturnptr      usage pointer.
       01 i                pic s9(9) comp-5.
       01 j                pic s9(9) comp-5.
       01 thissize         pic s9(9) comp-5.
       01 aptr             pointer.
       01 aptr2            pointer.
       01 aCopy            usage object reference.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 lnkreturnbuffer      COLLECTABLE.
       01 anelement            COLLECTABLE.
       01 lnkkey               KEYITEM.
       01 amessage             usage object reference.


       procedure division using amessage.
           invoke self "size" returning thissize
           set oonoquit to true
           move zero to i

           invoke self "allocateElement" returning ooreturnptr
           set address of lnkreturnbuffer to ooreturnptr

           invoke self "malloc" using keySize returning aptr
           set address of lnkkey to aptr

           invoke self "copy" returning aCopy

           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke aCopy "isEmptyAt" using j returning bool
               if isfalse
                   invoke aCopy "basicKeyAt" using j returning lnkKey
                   invoke amessage "invoke" using lnkkey
                                        returning lnkreturnbuffer
                   add 1 to i
               end-if
           end-perform
      $if gc defined
           if keytemplate = null
                call "oopsrelease" using
                                by value 1
                                by value lnkKey(1:objectreferencesize)
           else
                if keyHasObjects
                        invoke lnkKey(1:keysize) as keytemplate
                                "decreaseReferences"
                end-if

           end-if
      $end
           invoke aCopy "copy" returning aCopy
           invoke self "dealloc" using aptr

           invoke self "dealloc" using ooreturnptr
           set oonoquit to true
           exit method.
       end method "keysdo".
      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each key and data item associated with the association
      *> as a parameter.
      *> aMessage should be a CallBack pointing to a method which
      *> expects two parameters; the key and the data.
      *> For more information see the topic Collection Iterator Methods
      *> in the on-line documentation.
      *>---------------------------------------------------------------
       method-id. "keysAndDatado".
       local-storage section.
       01 i                pic s9(9) comp-5.
       01 j                pic s9(9) comp-5.
       01 thissize         pic s9(9) comp-5.
       01 aptr             pointer.
       01 aptr2            pointer.

       01 k                pic s9(9) comp-5.
       01 aCopy            usage object reference.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 lnkreturnbuffer       COLLECTABLE.
       01 lnkkey                KEYITEM.
       01 lnkdata               DATAITEM.
       01 amessage             usage object reference.

       procedure division using amessage.
           invoke self "size" returning thissize
           set oonoquit to true

           move collectionStride to i
           add keysize to i
           add datasize to i
           invoke self "malloc" using i returning aptr
           set aptr2 to aptr
           set address of lnkReturnBuffer to aptr

           set aptr2 up by collectionstride
           set address of lnkkey to aptr2

           set aptr2 up by keysize
           set address of lnkdata to aptr2

           move zero to i
           invoke self "copy" returning aCopy
           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke aCopy "isEmptyAt" using j returning bool
               if isfalse
                   invoke aCopy "basicKeyAt" using j returning lnkKey
                   invoke aCopy "basicDataAt" using j returning lnkData
                   invoke amessage "invoke" using lnkkey lnkdata
                                            returning lnkreturnbuffer
                   add 1 to i
               end-if
           end-perform
           invoke aCopy "finalize" returning aCopy
      $if gc defined
           if keytemplate = null
                call "oopsrelease" using by value 1
                                        lnkKey(1:keysize)
           else
                if keyHasObjects
                        invoke lnkKey(1:keysize) as keytemplate
                                "decreaseReferences"
                end-if

           end-if

           if collectiontemplate = null
                call "oopsrelease" using by value 1
                                        lnkData(1:datasize)
           else
                if dataHasObjects
                        invoke lnkData(1:datasize) as collectiontemplate
                                "decreaseReferences"
                        
                end-if

           end-if
      $end
           invoke self "dealloc" using aptr
           set oonoquit to true
           exit method.
       end method "keysAndDatado".
      *>---------------------------------------------------------------
      *> Raises an exception as it is not valid to remove anObject from
      *> a Dictionary
      *>---------------------------------------------------------------
       method-id. "remove".
       linkage section.
       01 anelement             COLLECTABLE.

       procedure division using anelement.
           invoke self "shouldNotImplement"
           exit method.
       end method "remove".
      *>---------------------------------------------------------------
      *> Return true if this dictionary includes the association
      *> anElement otherwise return false.
      *>---------------------------------------------------------------
       method-id. "includesAssociation".
       linkage section.
       01 anelement             COLLECTABLE.
       01 lnkbool                 pic x comp-5.
           88 lnkistrue           value 1.
           88 lnkisfalse          value 0.

       procedure division using anelement
                                         returning lnkbool.
           invoke super "includes" using anelement
                                         returning lnkbool.
           exit method.
       end method "includesAssociation".

      *>---------------------------------------------------------------
      *> Removes the association anElement from this dictionary.
      *>---------------------------------------------------------------
       method-id. "removeAssociation".
       local-storage section.
       01 bool                 pic x comp-5.
       01 i                    pic x(4) comp-5.
       01 lsElement            usage object reference.
       linkage section.
       01 anelement             COLLECTABLE.

       procedure division using anelement.
           if associationTemplate = null
               invoke self "findElement" using anElement
                   returning i
               invoke self "isOccuppiedAt" using i returning bool
               if bool = 1
                   invoke self "privateat" using i
                           returning lselement
               end-if
           end-if
           invoke super "remove" using anelement
           if associationTemplate = null and bool = 1
               invoke lsElement "finalize" returning lsElement
           end-if
           exit method.
       end method "removeAssociation".
      *>---------------------------------------------------------------
      *> Return true if this dictionary includes aKey otherwise
      *> return false.
      *>---------------------------------------------------------------
       method-id. "includesKey".
       local-storage section.

       01 i                pic s9(9) comp-5.

       linkage section.
       01 lnkbool                 pic x comp-5.
           88 lnkistrue           value 1.
           88 lnkisfalse          value 0.
       01 akey                  KEYITEM.

       procedure division using akey returning lnkbool.
           invoke self "findKey" using akey lnkbool returning i
           exit method.
       end method "includesKey".

      *>---------------------------------------------------------------
      *> Remove aKey from this dictionary. Raise an exception if this
      *> dictionary does not include aKey.
      *>---------------------------------------------------------------
       method-id. "removeKey".
       local-storage section.
       01 anElement            usage object reference.
       01 realindex            pic s9(9) comp-5.
       01 exceptionnumber  pic s9(9) comp-5.
       01 i                pic s9(9) comp-5.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.
       01 lsptr                 pointer.
       01 lsBuffer         pic x(bufferSize).
       linkage section.
       01 akey                  KEYITEM.
       01 instanceData          pic x.
       01 lnkElement            COLLECTABLE.

       procedure division using akey.
           invoke self "findKey" using akey bool returning i
           if isfalse
               move 12 to exceptionnumber
               invoke self "raiseException" using exceptionnumber
           else
               if associationTemplate = null
                   invoke self "privateat" using i
                           returning anelement
                   invoke anElement "finalize" returning anElement
               end-if
               compute realindex = (i - 1) * collectionstride + 1
               set address of instanceData to collptr
      $if GC defined
               if associationtemplate = null
                  call "oopsassignobjectreference" using
                    by reference instancedata(realindex:)
                    by value 0

               else
                  if storingobjects
                    if collectionStride <= buffersize
                        move low-values to lsBuffer
                        invoke lsBuffer(1:collectionStride)
                                AS associationTemplate "getvalue"
                           returning
                           instancedata(realindex:collectionStride)
                    else
                        invoke self "allocateElement" returning lsptr
                        set address of lnkElement to lsptr
                        invoke lnkElement(1:collectionStride)
                            as associationTemplate "getValue"
                            returning
                            instancedata(realindex:collectionstride)
                        invoke self "deallocate" using lsptr
                    end-if
                  else
                    move low-values to
                      instancedata(realindex:collectionstride)
                  end-if
               end-if
      $else
               move low-values to
                      instancedata(realindex:collectionstride)
      $end
               subtract 1 from numberelements
               invoke self "setEmpty" using i
               invoke self "fixCollisionsFrom" using i
           end-if
           exit method.
       end method "removeKey".
      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each data item associated with the association as a
      *> parameter.
      *> A new dictionary is created and returned in anewdictionary.
      *> aMessage should be a CallBack pointing to a method which
      *> expects a data item as a parameter and will return a pic x comp-5.
      *> If the CallBack returns False (that is 0), then that association
      *> is placed in the new dictionary.
      *> For more information see the topic Collection Iterator Methods
      *> in the on-line documentation.
      *>---------------------------------------------------------------
       method-id. "reject".
       local-storage section.
       01 i                pic s9(9) comp-5.
       01 j                pic s9(9) comp-5.
       01 thissize         pic s9(9) comp-5.
       01 aptr             pointer.
       01 aptr2            pointer.
       01 aCopy            usage object reference.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 anewdictionary       usage object reference.
       01 lnkdata              DATAITEM.
       01 lnkkey               KEYITEM.
       01 amessage             usage object reference.

       procedure division using amessage returning anewdictionary.
           invoke self "copyEmpty" returning anewdictionary
           invoke self "size" returning thissize
           set oonoquit to true
           move keysize to i
           add datasize to i
           invoke self "malloc" using i returning aptr
           set address of lnkKey to aptr

           set aptr2 to aptr
           set aptr2 up by keysize
           set address of lnkData to aptr2

           invoke self "copy" returning aCopy
           move zero to i
           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke aCopy "isEmptyAt" using j returning bool
               if isfalse
                   invoke aCopy "basicDataAt" using j returning lnkData
                   invoke amessage "invoke" using lnkdata
                                   returning bool
                   if isfalse
                       invoke aCopy "basicKeyAt"
                                        using j returning lnkKey
                       invoke anewdictionary "atPut"
                                        using lnkKey lnkData
                   end-if
                   add 1 to i
               end-if
           end-perform
      $if gc defined
           if keytemplate = null
                call "oopsrelease" using
                                by value 1
                                by value lnkKey(1:objectreferencesize)
           else
                if keyHasObjects
                        invoke lnkKey(1:keysize) as keytemplate
                                "decreaseReferences"
                end-if

           end-if

           if collectiontemplate = null
                call "oopsrelease" using
                                by value 1
                                by value lnkData(1:objectreferencesize)
           else
                if dataHasObjects
                        invoke lnkData(1:datasize) as collectiontemplate
                                "decreaseReferences"
                        
                end-if

           end-if

      $end
           invoke aCopy "finalize" returning aCopy
           invoke self "dealloc" using aptr
           set oonoquit to true
           exit method.
       end method "reject".


      *>---------------------------------------------------------------
      *> Send aMessage for every association within the dictionary
      *> passing each data item associated with the association as a
      *> parameter.
      *> A new dictionary is created and returned in anewdictionary.
      *> aMessage should be a CallBack pointing to a method which
      *> expects a data item as a parameter and will return a pic x comp-5.
      *> If the CallBack returns True (that is 1), then that association
      *> is placed in the new dictionary.
      *> For more information see the topic Collection Iterator Methods
      *> in the on-line documentation.
      *>---------------------------------------------------------------
       method-id. "select".
       local-storage section.
       01 i                pic s9(9) comp-5.
       01 j                pic s9(9) comp-5.
       01 thissize         pic s9(9) comp-5.
       01 aptr             pointer.
       01 aptr2            pointer.
       01 aCopy            usage object reference.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 anewdictionary       usage object reference.
       01 lnkdata              DATAITEM.
       01 lnkkey               KEYITEM.
       01 amessage             usage object reference.

       procedure division using amessage returning anewdictionary.
           invoke self "copyEmpty" returning anewdictionary
           invoke self "size" returning thissize
           set oonoquit to true

           move keysize to i
           add datasize to i
           invoke self "malloc" using i returning aptr
           set address of lnkKey to aptr

           set aptr2 to aptr
           set aptr2 up by keysize
           set address of lnkData to aptr2

           move zero to i
           invoke self "copy" returning aCopy
           perform varying j from 1 by 1 until i = thissize or ooquit
               invoke aCopy "isEmptyAt" using j returning bool
               if isfalse
                   invoke aCopy "basicDataAt" using j returning lnkData
                   invoke amessage "invoke" using lnkdata
                                   returning bool
                   if isTrue
                       invoke aCopy "basicKeyAt"
                                        using j returning lnkKey
                       invoke anewdictionary "atPut"
                                        using lnkKey lnkData
                   end-if
                   add 1 to i
               end-if
           end-perform
      $if gc defined
           if keytemplate = null
                call "oopsrelease" using
                                by value 1
                                by value lnkKey(1:objectreferencesize)
           else
                if keyHasObjects
                        invoke lnkKey(1:keysize) as keytemplate
                                "decreaseReferences"
                end-if

           end-if

           if collectiontemplate = null
                call "oopsrelease" using
                                by value 1
                                by value lnkData(1:objectreferencesize)
           else
                if dataHasObjects
                        invoke lnkData(1:datasize) as collectiontemplate
                                "decreaseReferences"
                        
                end-if
           end-if

      $end
           invoke aCopy "finalize" returning aCopy
           invoke self "dealloc" using aptr
           set oonoquit to true
           exit method.
       end method "select".


      *>----------------------------------------------------------------
      *> If aCollection is compatible with this collection then remove
      *> all the Associations in aCollection from this collection,
      *> otherwise raise an appropriate exception. ACollection must
      *> respond to associationsDo.
      *>----------------------------------------------------------------
       method-id. "removeAllAssociations".
       local-storage section.

       01 amessageselector     pic x(80).
       01 amessage2            usage object reference.
       01 bool                 pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.

       linkage section.
       01 acollection          usage object reference.

       procedure division using acollection.
           invoke self "isCompatible" using acollection
                                       returning bool
           if istrue
               move "removeAssociation" to amessageselector
               invoke callback "new" using self amessageselector
                                     returning amessage2
               invoke acollection "Associationsdo" using amessage2
               invoke amessage2 "finalize" returning aMessage2
           else
               invoke self "compatibilityError"
           end-if
           exit method.
       end method "removeAllAssociations".
      *>----------------------------------------------------------------
      *> Return a new collection of the same species, size and
      *> copies of all the elements. This will only provide a
      *> deep copy if the dictionary is storing associations. Therefore
      *> if the dictionary is storing key, data pairs then a shallow
      *> copy of the dictionary will be returned.
      *>----------------------------------------------------------------
       method-id. "deepcopy".
       working-storage section.
       01 aMessage      pic x(80) value "deepCopyBM ".
       01 lsSize        pic x(4) comp-5.

       local-storage section.
       01 abm           usage object reference.

       linkage section.
       01 anewcollection       usage object reference.

       procedure division returning anewcollection.
           if associationtemplate = null
               invoke self "capacity" returning lsSize
               invoke self "copyEmptyWithSize" using lsSize
                                       returning anewcollection
               invoke callback "new" using self  aMessage
                                       anewcollection
                             returning abm
               invoke self "Associationsdo" using abm
               invoke abm "finalize" returning abm
           else
               invoke self "copy" returning anewcollection
           end-if
           exit method.
       end method "deepcopy".
      *>----------------------------------------------------------------
      *> PRIVATE. Copy a member of this collection and add it to the new
      *> collection.
      *>----------------------------------------------------------------
       method-id. "deepcopyBM".
       local-storage section.
       01 anElement2           usage object reference.
       01 aKey2                usage object reference.
       01 aValue2              usage object reference.

       linkage section.
       01 lnkKey               usage object reference.
       01 lnkValue             usage object reference.
       01 anewcollection       usage object reference.
       01 anelement            usage object reference.

       procedure division using anewcollection anelement.
           if associationTemplate = null
               invoke anElement "deepcopy" returning anElement2
               invoke anewcollection "add" using anElement2
               invoke anElement2 "finalize" returning anElement2
           else
               if keyTemplate = null
                   invoke anElement "copy"
                               returning aKey2
                   set address of lnkKey to address of aKey2
               else
                   set address of lnkKey to address anElement
               end-if
               if collectionTemplate = null
                   invoke anElement(keySize + 1: objectreferencesize)
                         as object
                           "copy" returning aValue2
                   set address of lnkValue to address of aValue2
               else
                   set address of lnkValue
                           to address anElement(keySize + 1:)
               end-if
               invoke aNewCollection "atPut" using lnkKey lnkValue
           end-if
           exit method.
       end method "deepcopyBM".
      *>----------------------------------------------------------------
      *> Destroy all the elements and the collection, to a depth of
      *> lsDepth.
      *>----------------------------------------------------------------
       method-id. "deepfinalizeWithDepth".
       local-storage section.
       01 aMessage         pic x(80).
       01 lsDepth          pic x(4) comp-5.
       01 abm              usage object reference.
       linkage section.
       01 defaultreturn    usage object reference.
       01 lnkDepth         pic x(4) comp-5.
       procedure division using lnkDepth
                       returning defaultreturn.
           if lnkDepth > 0
               subtract 1 from lnkDepth giving lsDepth
               if associationtemplate = null
                   move "deepfinalizeBM2" to aMessage
                   invoke callback "new" using self aMessage lnkDepth
                             returning abm
               else
                   move "deepfinalizeBM" to aMessage
                   invoke callback "new" using self aMessage lsDepth
                             returning abm
               end-if
               invoke self "associationsDoWithOutCopy" using abm
               invoke abm "finalize" returning abm
               invoke super "finalize" returning defaultreturn
           else
               invoke self "finalize" returning defaultreturn
           end-if

           exit method.
       end method "deepfinalizeWithDepth".

      $if gc not defined  

      *>----------------------------------------------------------------
      *> Destroy this dictionary. If this dictionary was created
      *> via ofAssocaitions then all the associations are destroyed
      *> first.
      *>----------------------------------------------------------------
       method-id. "finalize".
       local-storage section.
       01 allAssocs        usage object reference.

       linkage section.
       01 defaultreturn    usage object reference.

       procedure division returning defaultreturn.
           if associationTemplate = null
               invoke self "associations" returning allAssocs
               invoke allAssocs "deepfinalize" returning allAssocs
           end-if
           invoke super "finalize" returning defaultReturn
           exit method.
       end method "finalize".
      $end

      *>----------------------------------------------------------------
      *> PRIVATE. Used to destroy intrinsic Associations
      *>----------------------------------------------------------------
       method-id. "deepfinalizeBM".
       local-storage section.
       01 temp             usage object reference.
       linkage section.
       01 lnkDepth        pic x(4) comp-5.
       01 lnkAssoc.
           03 lnkkey            KEYITEM.

       procedure division using lnkDepth lnkAssoc.
           if keyTemplate = null
               invoke lnkKey as Object "deepfinalizeWithDepth"
                       using lnkDepth
                   returning temp
           end-if
           if collectionTemplate = null
               invoke lnkAssoc(keySize + 1 : objectreferencesize)
                        AS OBJECT "deepfinalizeWithDepth"
                        using lnkDepth
                    returning temp
           end-if
           exit method.
       end method "deepfinalizeBM".

      *>----------------------------------------------------------------
      *> PRIVATE. Used to destroy Associations
      *>----------------------------------------------------------------
       method-id. "deepfinalizeBM2".
       local-storage section.
       01 temp             usage object reference.
       linkage section.
       01 lnkDepth         pic x(4) comp-5.
       01 lnkAssoc         usage object reference.

       procedure division using lnkDepth lnkAssoc.
           invoke lnkAssoc "deepfinalizeWithDepth"
                       using lnkDepth
                   returning temp
           exit method.
       end method "deepfinalizeBM2".

      *>---------------------------------------------------------------
      *> Store lnkData at aKey. If this dictionary does not contain aKey
      *> then it creates a new entry.
      *>---------------------------------------------------------------
       method-id. "atPut".
       local-storage section.

       01 realindex           pic s9(9) comp-5.
       01 i                   pic s9(9) comp-5.
       01 anassoc             usage object reference.
       01 bool                pic x comp-5.
           88 istrue           value 1.
           88 isfalse          value 0.
       01 growthLimit         pic x(4) comp-5.
       linkage section.
       01 akey                  KEYITEM.
       01 lnkdata               DATAITEM.
      $if GC not defined
       01 objectaspicx         pic x(4).
      $end
       01 instanceData         pic x.
       procedure division using akey lnkdata.
           multiply capacity by 7 giving growthLimit
           divide 10 into growthLimit
           if growthLimit <= numberelements
               invoke self "grow"
           end-if
           invoke self "findKey" using akey bool returning i
           compute realindex = (i - 1) * collectionstride + 1

           if isfalse
               invoke self "setOccuppied" using i
               add 1 to numberelements
               set address of instanceData to collptr
               if associationtemplate equal to null
                   invoke associationclass "keyData" using akey lnkdata
                                               returning anassoc

      $if GC defined
                   call "oopsassignobjectreference" using
                        by reference instancedata(realindex:)
                        by value anAssoc                   
      $else
                   set address of objectaspicx to address of anassoc
                   move objectaspicx(1:objectreferencesize) to
                       instancedata(realindex:objectreferencesize)
      $end  
               else
      $if GC defined
                   if keyhasobjects
                       invoke akey(1:keysize) AS keyTemplate
                        "getValue"
                          returning instancedata(realindex:keysize)
                   else
                       if keyTemplate = null
                           call "oopsassignobjectreference" using
                               by reference
                            instancedata(realindex:objectreferencesize)
                               by value akey(1:objectreferencesize)
                       else
                           move akey(1:keysize)
                            to instancedata(realindex:keysize)
                       end-if
                   end-if
                   if datahasObjects
                       invoke lnkdata(1:datasize) AS collectionTemplate
                        "getValue" returning
                           instancedata(realindex+keysize:datasize)

                   else
                       if collectionTemplate = null
                           call "oopsassignobjectreference" using
                               by reference
                               instancedata(realindex+keysize:
                                            objectreferencesize)
                               by value lnkData(1:objectreferencesize)
                       else
                           move lnkdata(1:datasize) to
                               instancedata(realindex+keysize:datasize)
                       end-if

                   end-if
      $else
                   move akey(1:keysize)
                                to instancedata(realindex:keysize)
                   move lnkdata(1:datasize) to
                       instancedata(realindex+keysize:datasize)
      $end  
               end-if
           else
               if associationtemplate equal to null
                   invoke self "privateat" using i
                                             returning anassoc
                   invoke anassoc "setData" using lnkdata
               else
      $if GC defined
                   set address of instanceData to collptr
                   if collectiontemplate = null
                      call "oopsassignobjectreference" using
                        by reference instancedata(realindex+keysize:
                                        objectreferencesize)
                        by value lnkdata(1:objectreferencesize)
                   else
                      if dataHasObjects
                         invoke lnkData(1:datasize)
                             as collectionTemplate "getValue"
                             returning
                             instancedata(realindex+keysize:datasize)
                      else
                         move lnkdata(1:datasize) to
                             instancedata(realindex+keysize:datasize)
                      end-if
                   end-if

      $else
                   set address of instanceData to collptr
                   move lnkdata(1:datasize) to
                       instancedata(realindex+keysize:datasize)
      $end  
               end-if
           end-if
           exit method.
       end method "atPut".

      *>---------------------------------------------------------------
      *> PRIVATE. Return address of element at position anIndex
      *>---------------------------------------------------------------
       method-id. "basicKeyAt".
       local-storage section.
       01 realindex           pic s9(9) comp-5.
       01 anAddress           usage pointer.
       linkage section.
       01 anindex             pic s9(9) comp-5.
       01 lnkKey              KEYITEM.
       01 anElement2          COLLECTABLE.

       procedure division using anindex returning lnkKey.
           subtract 1 from anIndex giving realIndex
           multiply collectionStride by realIndex

           set anaddress to collptr
           set anaddress up by realindex
           set address of anElement2 to anAddress

           if associationTemplate = null
                invoke anElement2 AS object "getKey"
                                returning lnkKey
           else

      $if gc defined
                if keytemplate = null
                    call "oopsassignobjectreference"
                        using by reference lnkKey(1:objectreferencesize)
                        by value anElement2(1:objectreferencesize)
                else
                    if keyhasobjects
                        invoke anElement2(1:keysize) as keytemplate
                           "getValue" returning lnkKey(1:keysize)
                    else
                        move anElement2(1:keysize)
                            to lnkKey(1:keysize)

                    end-if
                end-if
      $else  
                move anElement2(1:keysize)
                        to lnkKey(1:keysize)
      $end
           end-if
           exit method.
       end method "basicKeyAt".

      *>---------------------------------------------------------------
      *> PRIVATE. Return address of element at position anIndex
      *>---------------------------------------------------------------
       method-id. "basicDataAt".
       local-storage section.
       01 realindex           pic s9(9) comp-5.
       01 anAddress           usage pointer.
       linkage section.
       01 anindex             pic s9(9) comp-5.
       01 lnkData             DATAITEM.
       01 anElement2          COLLECTABLE.

       procedure division using anindex returning lnkData.
           subtract 1 from anIndex giving realIndex
           multiply collectionStride by realIndex

           set anaddress to collptr
           set anaddress up by realindex
           set address of anElement2 to anAddress

           if associationTemplate = null
                invoke anElement2 AS object "getData"
                                returning lnkData
           else

      $if gc defined
                if collectiontemplate = null
                    call "oopsassignobjectreference" using 
                        by reference lnkData(1 : datasize)
                        by value anElement2(1 + keysize :
                                    objectreferencesize)
                else
                    if dataHasObjects
                       invoke anElement2(1 + keysize : datasize)
                          AS collectionTemplate "getValue"
                          returning lnkData(1  : datasize)
                    else
                       move anElement2(1 + keysize : datasize)
                        to lnkData(1  : datasize)
                    end-if
                end-if
      $else  
                move anElement2(1 + keysize : datasize)
                        to lnkData(1 : datasize)

      $end
           end-if
           exit method.
       end method "basicDataAt".

      *>---------------------------------------------------------------
      *> PRIVATE. Return address of element at position anIndex
      *>---------------------------------------------------------------
       method-id. "basicAt".
       local-storage section.
       01 realindex           pic s9(9) comp-5.
       01 anAddress           usage pointer.
       linkage section.
       01 anindex              pic s9(9) comp-5.
       01 anElement           COLLECTABLE.
       01 anElement2          COLLECTABLE.

       procedure division using anindex returning anElement.
           subtract 1 from anIndex giving realIndex
           multiply collectionStride by realIndex

           set anaddress to collptr
           set anaddress up by realindex
           set address of anElement2 to anAddress

      $if gc defined
           if associationTemplate = null
                call "oopsassignobjectreference"
                        using by reference
                                 anElement(1:objectreferencesize)
                        by value anElement2(1:objectreferencesize)
           else
                if keytemplate = null
                    call "oopsassignobjectreference"
                        using by reference
                                 anElement(1:objectreferencesize)
                        by value anElement2(1:objectreferencesize)
                else
                    if keyhasobjects
                        invoke anElement2(1:keysize) as keytemplate
                          "getValue" returning anELement(1:keysize)
                    else
                        move anElement2(1:keysize)
                            to anElement(1:keysize)
                    end-if
                end-if

                if collectiontemplate = null
                    call "oopsassignobjectreference" using 
                        by reference
                            anElement(1 + keysize:objectreferencesize)
                        by value
                            anElement2(1 + keysize:objectreferencesize)
                else
                    if datahasobjects
                        invoke anElement2(1 + keysize : datasize)
                           AS collectiontemplate "getValue"
                           returning anElement(1 + keysize : datasize)
                    else
                        move anElement2(1 + keysize : datasize)
                            to anElement(1 + keysize : datasize)

                    end-if
                end-if

           end-if
      $else  
           move anElement2(1:collectionStride)
                        to anElement(1:collectionStride)
      $end  
           exit method.
       end method "basicAt".

      *>----------------------------------------------------------------
      *> Cause this ValueSet collection to become larger in order
      *> to store more members.
      *>----------------------------------------------------------------
       method-id. "grow".
       local-storage section.
       01 lsAssocs              usage object reference.

       procedure division.
           if associationTemplate = null
               invoke self "associations" returning lsAssocs
           end-if
           invoke super "grow"
           if associationTemplate = null
               invoke lsAssocs "deepfinalize" returning lsAssocs
           end-if
           exit method.
       end method "grow".

       end object.
       end class dictionary.
