      $set repository(update on checking on)
      *-----------------------------------------------------------------
       class-id. PLinkList as "PLinkList" inherits Base using fparam1.

       repository.
      $if formalParam = "interface"
           interface fparam1
      $else
           class fparam1
      $end
           class LinkEntry as "LEntry"
           class Base as "base"
           property nextElement
           property element
           .

       factory.

      *---------------------------------------------
      *
      * new: creates new linked list, initialise head an tail pointers
      *
      *---------------------------------------------
       method-id. "new".
       linkage section.
       01 newObject usage object reference PLinkList.
       procedure division returning newObject.
           invoke super "new" returning newObject
           invoke newObject  "initlinkedlist"
           exit method
       end method "new".

       end factory.
      *-----------------------------------------------------------------

       object.
       working-storage section.
       01 head object reference LinkEntry.
       01 tail object reference LinkEntry.
       01 posn object reference LinkEntry.
       01 listSize usage binary-long property no set.

      *---------------------------------------------
      *
      * initLinkedList:  initialise head an tail pointers
      *
      *---------------------------------------------

       method-id. "initLinkedList".
       local-storage section.
       01  tmp-element usage object reference fparam1.
       procedure division.
           move 0 to listSize
           set tmp-element to null
           invoke LinkEntry "newentry" using by value tmp-element
                                  returning head
           set tail to head
           set posn to null
           exit method
       end method "initLinkedList".

      *---------------------------------------------
      *
      * add: add element to end of linked list
      *
      *---------------------------------------------
       method-id. "add".
       01 newEntry usage object reference LinkEntry.
       linkage section.
       01 lk-element usage object reference fparam1.
       procedure division using by value lk-element.
           set newEntry to LinkEntry::"newentry"(lk-element)
           set nextElement of tail to newEntry
           set tail to newEntry
           add 1 to listSize
           exit method.
       end method "add".

      *---------------------------------------------
      *
      * getFirst: get first element on linked list
      *           returns null if no items in list
      *
      *---------------------------------------------
       method-id. "getFirst".
       local-storage section.
       01 tmp-element usage object reference.
       linkage section.
       01  lk-element usage object reference fparam1.
       procedure division returning lk-element.
           move nextElement of head to posn
           set tmp-element to element of posn
           set lk-element to tmp-element as fparam1
           exit method
       end method "getFirst".

      *---------------------------------------------
      *
      * getFirst: get first element on linked list
      *           returns null reached end of list
      *
      *---------------------------------------------

       method-id. "getNext".
       local-storage section.
       01 tmp-element usage object reference.
       linkage section.
       01  lk-element usage object reference fparam1.
       procedure division returning lk-element.
           move nextElement of posn to posn
           if posn = null
               set lk-element to null
           else
               set tmp-element to element of posn
               set lk-element to tmp-element as fparam1
           end-if
           exit method
       end method "getNext".

       end object.
           
       end class PLinkList.

