-- a LIST is a collection with fixed order. -- Elements can occur any number of times. -- Time complexity for data adding is O(1). -- Time complexity for data searching is O(n). -- Space complexity is O(n). indexing names: list, chain; contents: generic; author: "Guichard Damien"; created: 9,November,1995; modified: 9,November,1995 class LIST inherit BAG redefine add end feature add (element:BAG) is -- Add an element to the list. do if next = Void then next := element end if last /= Void then last.set_next(element) last := element end -- add item (i:INTEGER):BAG is -- Find i-th list item (from 1). require -- i > 0 local n:INTEGER do from Result := Current until n = i or Result = Void variant -- i - n loop Result := Result.next n := n + 1 end end -- item feature{NONE} last:BAG end -- class 'LIST'