------------------------->  GNU Sather - sourcefile  <-------------------------
-- Copyright (C) 2000 by K Hopper, University of Waikato, New Zealand        --
-- This file is part of the GNU Sather library. It is free software; you may --
-- redistribute  and/or modify it under the terms of the GNU Library General --
-- Public  License (LGPL)  as published  by the  Free  Software  Foundation; --
-- either version 2 of the license, or (at your option) any later version.   --
-- This  library  is distributed  in the  hope that it will  be  useful, but --
-- WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See Doc/LGPL for more details.       --
-- The license text is also available from:  Free Software Foundation, Inc., --
-- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                     --
-------------->  Please email comments to <bug-sather@gnu.org>  <--------------

abstract class $LISTS{ETP} < $ARR{ETP} is

--        This abstract class provides an extensible list abstraction. This has
--   keys which because of its parentage are cardinal numbers.

--         Version 1.0 Nov 2000.   Copyright K Hopper, U of Waikato

--                          Development History
--                          -------------------

--        Date           Who By         Detail
--        ----           ------         ------

--       28 Nov 00        kh       Original when simplifying inheritance.

create : SAME ;

--        This version of creation produces a default list which is empty.


create(
       size : CARD
       ) : SAME ;

--        This feature creates a new list with at least the given size, all of
--   the elements of which are empty.


count(
      val : ETP
      ) : CARD ;

--        This feature returns the number of elements in the list which have
--   the given value.

end ; --$LISTS{ETP}

------------------------------------------------------------------------------

abstract class $FLISTS{ETP} < $LISTS{ETP} is

--        This abstract class provides an extensible list abstraction of a
--   mutable list.  This has keys which because of its parentage are cardinal
--   numbers.

--         Version 1.0 Nov 2000.   Copyright K Hopper, U of Waikato

--                          Development History
--                          -------------------

--        Date           Who By         Detail
--        ----           ------         ------

--       28 Nov 00        kh       Original when simplifying inheritance.

create(
       contents : ARRAY{ETP}
       ) : SAME ;

--        This feature creates a new list with at least the size of the
--   argument array, into which the contents of the array has been copied
--   sequentially.


array : $ARR{ETP} ;

--        This feature returns the a new array into which the contents of self
--   has been placed sequentially.


clear ;

--        This feature clears the contents of the list to be the empty list.


is_full : BOOL ;

--        This predicate returns true if and only if the buffer for this list
--   has no more empty space.


push(
     val : ETP
     ) : SAME ;

--        This feature returns a (possibly new) list with the contents of self
--   to which has been appended the given element.

end ; --$FLISTS{ETP}

------------------------------------------------------------------------------

abstract class $LIST{ETP} < $LISTS{ETP} is

--        This abstract class provides an extensible array abstraction. Similar
--   to a list abstraction, this has keys which are cardinal numbers.   After
--   an insertion some keys may have changed.

--         Version 1.3 Nov 2000.   Copyright K Hopper, U of Waikato

--                          Development History
--                          -------------------

--        Date           Who By         Detail
--        ----           ------         ------

--        5 Sep 96        bv       Original
--        3 Apr 97        kh       Changed for CARD instead of INT
--        6 Nov 98        kh       Revised for 1.2, added pre/post conditions
--       28 Nov 00        kh       Revised inheritance type graph.


equals(
       other : $RO_ARR{ETP}
       ) : BOOL ;

--        This routine returns true if and only if all elements of self are
--   equal to all elements of other when taken in the same order.


insert_after(
            index : CARD,
            val : ETP
            ) ;

--        This inserts val immediately after the given index position.   The
--   indices of all subwequent elements will have increased by one.


insert_after(
            index : CARD,
            val : ETP
            ) : SAME ;

--        This inserts val immediately after the given index position in a copy
--   of self.   The indices of all subsequent elements will have increased by
--   one.  The resulting list is returned.


insert_before(
             index : CARD,
             val : ETP
             ) ;

--        This inserts the value val in the position immediately before the
--   given index.   The indices of all subsequent elements will be increased
--   by one.


insert_before(
             index : CARD,
             val : ETP
             ) : SAME ;

--        This inserts the value val in the position immediately before the
--   given index in a copy of self.   The indices of all subsequent elements
--   will be increased by one.   The resultant list is returned.


insert_all_before(
                 index : CARD,
                 val : $CONTAINER{ETP}
                 ) ;

--        This inserts all of the items in val in order at the position before
--   the given index.   All subsequent elements will have their index increased
--   by the number of elements in val.


insert_all_before(
                 index : CARD,
                 val : $CONTAINER{ETP}
                 ) : SAME ;

--        This inserts all of the items in val in order at the position before
--   the given index in a copy of self.   All subsequent elements will have
--   their index increased by the number of elements in val.  The resultant
--   list is returned.


insert_all_after(
                 index : CARD,
                 val : $CONTAINER{ETP}
                 ) ;

--        This inserts all of the items in val in order at the position after
--   the given index.   All subsequent elements will have their index increased
--   by the number of elements in val.


insert_all_after(
                 index : CARD,
                 val : $CONTAINER{ETP}
                 ) : SAME ;

--        This inserts all of the items in val in order at the position after
--   the given index in a copy of self.   All subsequent elements will have
--   their index increased by the number of elements in val.  The resultant
--   list is returned.


append(
      elem : ETP
      ) ;

--        This concatenates elem at the end of the existing list.


append(
      elem : ETP
      ) : SAME ;

--        This concatenates elem at the end of a copy of the existing list
--   before returning the result..


append_all(
           list : $CONTAINER{ETP}
           ) ;

--        This concatenates the given list after self.


append_all(
           list : $CONTAINER{ETP}
           ) : SAME ;

--        This concatenates the given list after copying self and before
--   returning the resultant list.

end ; -- $LIST{ETP}

