dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Dotgnu-pnet-commits] CVS: pnetlib/Generics LinkedList.cs,NONE,1.1 ReadO


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/Generics LinkedList.cs,NONE,1.1 ReadOnlyIterator.cs,NONE,1.1 ArrayList.cs,1.1,1.2 Generics.txt,1.1,1.2 List.cs,1.1,NONE
Date: Fri, 21 Feb 2003 22:54:06 -0500

Update of /cvsroot/dotgnu-pnet/pnetlib/Generics
In directory subversions:/tmp/cvs-serv2899/Generics

Modified Files:
        ArrayList.cs Generics.txt 
Added Files:
        LinkedList.cs ReadOnlyIterator.cs 
Removed Files:
        List.cs 
Log Message:


Read-only iterators; rename List<T> to LinkedList<T>; finish
implementing LinkedList<T>.


--- NEW FILE ---
/*
 * LinkedList.cs - Generic doubly-linked list class.
 *
 * Copyright (c) 2003  Southern Storm Software, Pty Ltd
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
[...971 lines suppressed...]
                                {
                                        throw new InvalidOperationException
                                                (S._("NotSupp_ReadOnly"));
                                }
                public override bool Remove(IEnumerator<T> e)
                                {
                                        throw new InvalidOperationException
                                                (S._("NotSupp_ReadOnly"));
                                }
                public override bool RemoveAndMoveToPrev(IEnumerator<T> e)
                                {
                                        throw new InvalidOperationException
                                                (S._("NotSupp_ReadOnly"));
                                }

        }; // class ReadOnlyList<T>

}; // class LinkedList<T>

}; // namespace Generics

--- NEW FILE ---
/*
 * ReadOnlyIterator.cs - Wrap an iterator to make it read-only.
 *
 * Copyright (C) 2003  Southern Storm Software, Pty Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program 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 the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

namespace Generics
{

using System;

internal sealed class ReadOnlyIterator<T> : IEnumerator<T>, IIterator<T>
{
        // Internal state.
        protected IIterator<T> iterator;

        // Constructor.
        public ReadOnlyIterator(IIterator<T> iterator)
                        {
                                this.iterator = iterator;
                        }

        // Implement the IEnumerator<T> interface.
        public bool MoveNext()
                        {
                                return iterator.MoveNext();
                        }
        public void Reset()
                        {
                                iterator.Reset();
                        }
        T IEnumerator<T>.Current
                        {
                                get
                                {
                                        return 
((IEnumerator<T>)iterator).Current;
                                }
                        }

        // Implement the IIterator<T> interface.
        public bool MovePrev()
                        {
                                return iterator.MovePrev();
                        }
        public T Current
                        {
                                get
                                {
                                        return iterator.Current;
                                }
                                set
                                {
                                        throw new InvalidOperationException
                                                (S._("NotSupp_ReadOnly"));
                                }
                        }

}; // class ReadOnlyIterator<T>

}; // namespace Generics

Index: ArrayList.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/ArrayList.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** ArrayList.cs        22 Feb 2003 02:56:20 -0000      1.1
--- ArrayList.cs        22 Feb 2003 03:54:04 -0000      1.2
***************
*** 2051,2054 ****
--- 2051,2065 ----
                                }
  
+               // Get an iterator for this array list.
+               public override IIterator<T> GetIterator()
+                               {
+                                       return new 
ReadOnlyIterator<T>(list.GetIterator());
+                               }
+               public override IIterator<T> GetIterator(int index, int count)
+                               {
+                                       return new ReadOnlyIterator<T>
+                                               (list.GetIterator(index, 
count));
+                               }
+ 
        }; // class ReadOnlyWrapper<T>
  

Index: Generics.txt
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/Generics.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** Generics.txt        22 Feb 2003 02:56:20 -0000      1.1
--- Generics.txt        22 Feb 2003 03:54:04 -0000      1.2
***************
*** 38,41 ****
--- 38,42 ----
  Invalid_UnderlyingModified=The underlying collection has been modified
  Invalid_ValueType=Invalid type for collection value
+ Invalid_Enumerator=Enumerator does not belong to the specified collection
  NotSupp_FixedSizeCollection=Operation not supported on fixed sized objects
  NotSupp_ReadOnly=Operation not supported on read-only objects

--- List.cs DELETED ---





reply via email to

[Prev in Thread] Current Thread [Next in Thread]