Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

TypedLinkedList.java

00001 package ca.mcgill.sable.util;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * SableUtil, a clean room implementation of the Collection API.     *
00005  * Copyright (C) 1997, 1998 Etienne Gagnon (gagnon@sable.mcgill.ca). *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project of the Sable Research Group,      *
00009  * School of Computer Science, McGill University, Canada             *
00010  * (http://www.sable.mcgill.ca/).  It is understood that any         *
00011  * modification not identified as such is not covered by the         *
00012  * preceding statement.                                              *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this library; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * To submit a bug report, send a comment, or get the latest news on *
00030  * this project and other Sable Research Group projects, please      *
00031  * visit the web site: http://www.sable.mcgill.ca/                   *
00032  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
00033 
00034 /*
00035  Reference Version
00036  -----------------
00037  This is the latest official version on which this file is based.
00038  The reference version is: $SableUtilVersion: 1.11 $
00039 
00040  Change History
00041  --------------
00042  A) Notes:
00043 
00044  Please use the following template.  Most recent changes should
00045  appear at the top of the list.
00046 
00047  - Modified on [date (March 1, 1900)] by [name]. [(*) if appropriate]
00048    [description of modification].
00049 
00050  Any Modification flagged with "(*)" was done as a project of the
00051  Sable Research Group, School of Computer Science,
00052  McGill University, Canada (http://www.sable.mcgill.ca/).
00053 
00054  You should add your copyright, using the following template, at
00055  the top of this file, along with other copyrights.
00056 
00057  *                                                                   *
00058  * Modifications by [name] are                                       *
00059  * Copyright (C) [year(s)] [your name (or company)].  All rights     *
00060  * reserved.                                                         *
00061  *                                                                   *
00062 
00063  B) Changes:
00064 
00065  - Modified on June 7, 1998 by Etienne Gagnon (gagnon@sable.mcgill.ca). (*)
00066    Changed the license.
00067 */
00068 
00069 public class TypedLinkedList extends LinkedList
00070 {
00071     Cast cast;
00072 
00073     private class TypedLinkedListIterator implements ListIterator
00074     {
00075         ListIterator iterator;
00076 
00077         TypedLinkedListIterator(ListIterator iterator)
00078         {
00079             this.iterator = iterator;
00080         }
00081 
00082         public boolean hasNext()
00083         {
00084             return iterator.hasNext();
00085         }
00086 
00087         public Object next()
00088         {
00089             return iterator.next();
00090         }
00091 
00092         public boolean hasPrevious()
00093         {
00094             return iterator.hasPrevious();
00095         }
00096 
00097         public Object previous()
00098         {
00099             return iterator.previous();
00100         }
00101 
00102         public int nextIndex()
00103         {
00104             return iterator.nextIndex();
00105         }
00106 
00107         public int previousIndex()
00108         {
00109             return iterator.previousIndex();
00110         }
00111 
00112         public void remove()
00113         {
00114             iterator.remove();
00115         }
00116 
00117         public void set(Object o)
00118         {
00119             iterator.set(cast.cast(o));
00120         }
00121 
00122         public void add(Object o)
00123         {
00124             iterator.add(cast.cast(o));
00125         }
00126     }
00127     public TypedLinkedList()
00128     {
00129         super();
00130 
00131         cast = NoCast.instance;
00132     }
00133     public TypedLinkedList(Cast cast)
00134     {
00135         super();
00136 
00137         this.cast = cast;
00138     }
00139     public TypedLinkedList(Collection c)
00140     {
00141         super(c);
00142 
00143         cast = NoCast.instance;
00144     }
00145     public TypedLinkedList(Collection c, Cast cast)
00146     {
00147         super(c);
00148 
00149         this.cast = cast;
00150     }
00151     public void addFirst(Object o)
00152     {
00153         super.addFirst(cast.cast(o));
00154     }
00155     public void addLast(Object o)
00156     {
00157         super.addLast(cast.cast(o));
00158     }
00159     public Cast getCast()
00160     {
00161         return cast;
00162     }
00163     public ListIterator listIterator(int index)
00164     {
00165         return new TypedLinkedListIterator(super.listIterator(index));
00166     }
00167 }

Generated at Thu Feb 7 06:58:43 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001