1-- Copyright 1994 Grady Booch 2-- Copyright 2003-2014 Simon Wright <simon@pushface.org> 3 4-- This package is free software; you can redistribute it and/or 5-- modify it under terms of the GNU General Public License as 6-- published by the Free Software Foundation; either version 2, or 7-- (at your option) any later version. This package is distributed in 8-- the hope that it will be useful, but WITHOUT ANY WARRANTY; without 9-- even the implied warranty of MERCHANTABILITY or FITNESS FOR A 10-- PARTICULAR PURPOSE. See the GNU General Public License for more 11-- details. You should have received a copy of the GNU General Public 12-- License distributed with this package; see file COPYING. If not, 13-- write to the Free Software Foundation, 59 Temple Place - Suite 14-- 330, Boston, MA 02111-1307, USA. 15 16-- As a special exception, if other files instantiate generics from 17-- this unit, or you link this unit with other files to produce an 18-- executable, this unit does not by itself cause the resulting 19-- executable to be covered by the GNU General Public License. This 20-- exception does not however invalidate any other reasons why the 21-- executable file might be covered by the GNU Public License. 22 23with BC.Support.Unmanaged; 24 25generic 26package BC.Containers.Rings.Unmanaged is 27 28 pragma Preelaborate; 29 30 type Ring is new Abstract_Ring with private; 31 32 function Null_Container return Ring; 33 34 function "=" (Left, Right : in Ring) return Boolean; 35 36 procedure Clear (R : in out Ring); 37 -- Empty the ring of all items. The mark is cleared. 38 39 procedure Insert (R : in out Ring; Elem : Item); 40 -- If the ring was empty, set the ring's mark and top to designate 41 -- this item. 42 -- Otherwise, 43 -- this item becomes the new top; 44 -- the previous top is located one place forward of the new top; 45 -- the mark remains on the previously marked item. 46 47 procedure Pop (R : in out Ring); 48 -- Remove the top item from the ring. 49 -- If the ring is still not empty, the new top is the item that was 50 -- previously one place forward from the top. 51 -- If the removed item was the marked item, the mark now designates 52 -- the new top. 53 54 function Extent (R : Ring) return Natural; 55 -- Return the number of items in the ring. 56 57 function Is_Empty (R : Ring) return Boolean; 58 -- Return True if and only if there are no items in the ring. 59 60 function Top (R : Ring) return Item; 61 -- Return a copy of the item at the top of the ring. 62 63 function New_Iterator (For_The_Ring : Ring) return Iterator'Class; 64 -- Return a reset Iterator bound to the specific Ring. 65 66private 67 68 procedure Add (R : in out Ring; Elem : Item); 69 function Item_At (R : Ring; Index : Positive) return Item_Ptr; 70 71 package Ring_Nodes 72 is new BC.Support.Unmanaged (Item => Item, 73 Item_Ptr => Item_Ptr); 74 75 type Ring is new Abstract_Ring with record 76 Rep : Ring_Nodes.Unm_Node; 77 end record; 78 79end BC.Containers.Rings.Unmanaged; 80