      *>----------------------------------------------------------------
      *> An instance of IdentitySet is a collection of
      *> non-ordered objects or intrinsics. Duplicates are not allowed
      *> in an IdentitySet.
      *>
      *> An IdentitySet is more specific than a ValueSet as it compares
      *> object references instead of values. For example, if you asked
      *> it to find the element myElement it would only find it if
      *> the IdentitySet contained the same object reference as
      *> myElement.
      *>
      *>#See class "valueset".
      *>
      *> Copyright (C) 1991-1999 Micro Focus International Ltd.
      *>
      *>----------------------------------------------------------------
      $set localcount(200) linkcount(150) mfoo
       class-id. IdentitySet data is protected
               inherits from ValueSet with data.


        object section.
        class-control.
           IdentitySet is class "iset"
           ValueSet is class "valueset".

       class-object.
       object-storage section.
       end class-object.


       Object.
       object-storage section.

      *>----------------------------------------------------------------
      *> PRIVATE. Returns true if anElement is at the real index position
      *> anIndex otherwise returns false.
      *>----------------------------------------------------------------
       method-id. "isat".
       local-storage section.
       01 lsBUffer         pic x(bufferSize).
       01 aptr             pointer.

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

       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
                   set address of anElement2 to address of lsBuffer
               end-if
               invoke self "basicat" using anindex returning anElement2
               if anelement2(1:collectionStride)
                        = anelement(1:collectionStride)
                  set lnkistrue to true
               else
                  set lnkisfalse to true
               end-if
               if collectionStride > bufferSize
                   invoke self "dealloc" using aptr
               end-if
           end-if
           exit method.
       end method "isat".
      *>---------------------------------------------------------------
      *> PRIVATE. Returns the index of the anElement or an index for
      *> where anElement can be stored if it doesn't exist
      *>---------------------------------------------------------------
       method-id. "findElement".
       local-storage section.

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

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

       procedure division using anelement returning anindex.
           move capacity to asize
           if collectiontemplate equal to null
               move anelement(1:objectreferencesize)
                    to hashvalue(1:objectreferencesize)
           else
               invoke anelement as collectiontemplate
                               "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".

       end object.
       end class IdentitySet.
