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 ArrayQueue.cs,1.4,1.5 Array


From: Rhys Weatherley <address@hidden>
Subject: [Dotgnu-pnet-commits] CVS: pnetlib/Generics ArrayQueue.cs,1.4,1.5 ArrayStack.cs,1.4,1.5 FixedSizeQueue.cs,1.1,1.2 FixedSizeStack.cs,1.1,1.2 IQueue.cs,1.3,1.4 IStack.cs,1.3,1.4 LinkedList.cs,1.6,1.7 ReadOnlyQueue.cs,1.2,1.3 ReadOnlyStack.cs,1.2,1.3 SynchronizedQueue.cs,1.1,1.2 SynchronizedStack.cs,1.1,1.2
Date: Mon, 24 Feb 2003 19:43:45 -0500

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

Modified Files:
        ArrayQueue.cs ArrayStack.cs FixedSizeQueue.cs 
        FixedSizeStack.cs IQueue.cs IStack.cs LinkedList.cs 
        ReadOnlyQueue.cs ReadOnlyStack.cs SynchronizedQueue.cs 
        SynchronizedStack.cs 
Log Message:


Add "Clear" and "Contains" to the IQueue and IStack interfaces.


Index: ArrayQueue.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/ArrayQueue.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ArrayQueue.cs       24 Feb 2003 10:01:00 -0000      1.4
--- ArrayQueue.cs       25 Feb 2003 00:43:42 -0000      1.5
***************
*** 28,32 ****
  using System;
  
! public class ArrayQueue<T> : IQueue<T>, ICloneable
  {
        // Internal state.
--- 28,32 ----
  using System;
  
! public sealed class ArrayQueue<T> : IQueue<T>, ICloneable
  {
        // Internal state.
***************
*** 78,97 ****
                                this.growFactor = growFactor;
                        }
-       public ArrayQueue(ICollection<T> col)
-                       {
-                               if(col == null)
-                               {
-                                       throw new ArgumentNullException("col");
-                               }
-                               items = new T [col.Count];
-                               col.CopyTo(items, 0);
-                               add = 0;
-                               remove = 0;
-                               size = items.Length;
-                               growFactor = 2.0f;
-                       }
  
        // Implement the ICollection<T> interface.
!       public virtual void CopyTo(T[] array, int index)
                        {
                                if(array == null)
--- 78,84 ----
                                this.growFactor = growFactor;
                        }
  
        // Implement the ICollection<T> interface.
!       public void CopyTo(T[] array, int index)
                        {
                                if(array == null)
***************
*** 123,127 ****
                                }
                        }
!       public virtual int Count
                        {
                                get
--- 110,114 ----
                                }
                        }
!       public int Count
                        {
                                get
***************
*** 130,134 ****
                                }
                        }
!       public virtual bool IsSynchronized
                        {
                                get
--- 117,121 ----
                                }
                        }
!       public bool IsSynchronized
                        {
                                get
***************
*** 137,141 ****
                                }
                        }
!       public virtual Object SyncRoot
                        {
                                get
--- 124,128 ----
                                }
                        }
!       public Object SyncRoot
                        {
                                get
***************
*** 146,150 ****
  
        // Implement the ICloneable<T> interface.
!       public virtual Object Clone()
                        {
                                ArrayQueue<T> queue = 
(ArrayQueue<T>)MemberwiseClone();
--- 133,137 ----
  
        // Implement the ICloneable<T> interface.
!       public Object Clone()
                        {
                                ArrayQueue<T> queue = 
(ArrayQueue<T>)MemberwiseClone();
***************
*** 154,164 ****
  
        // Implement the IIterable<T> interface.
!       public virtual IIterable<T> GetIterator()
                        {
                                return new QueueIterator<T>(this);
                        }
  
!       // Clear the contents of this queue.
!       public virtual void Clear()
                        {
                                add = 0;
--- 141,151 ----
  
        // Implement the IIterable<T> interface.
!       public IIterable<T> GetIterator()
                        {
                                return new QueueIterator<T>(this);
                        }
  
!       // Implement the IQueue<T> interface.
!       public void Clear()
                        {
                                add = 0;
***************
*** 166,172 ****
                                size = 0;
                        }
! 
!       // Determine if this queue contains a specific object.
!       public virtual bool Contains(T obj)
                        {
                                int index = remove;
--- 153,157 ----
                                size = 0;
                        }
!       public bool Contains(T obj)
                        {
                                int index = remove;
***************
*** 206,212 ****
                                return false;
                        }
! 
!       // Implement the IQueue<T> interface.
!       public virtual void Enqueue(T value)
                        {
                                if(size < items.Length)
--- 191,195 ----
                                return false;
                        }
!       public void Enqueue(T value)
                        {
                                if(size < items.Length)
***************
*** 242,246 ****
                                }
                        }
!       public virtual T Dequeue()
                        {
                                if(size > 0)
--- 225,229 ----
                                }
                        }
!       public T Dequeue()
                        {
                                if(size > 0)
***************
*** 257,261 ****
                                }
                        }
!       public virtual T Peek()
                        {
                                if(size > 0)
--- 240,244 ----
                                }
                        }
!       public T Peek()
                        {
                                if(size > 0)
***************
*** 269,273 ****
                                }
                        }
!       public virtual T[] ToArray()
                        {
                                T[] array = new T [size];
--- 252,256 ----
                                }
                        }
!       public T[] ToArray()
                        {
                                T[] array = new T [size];
***************
*** 288,292 ****
                                return array;
                        }
!       public virtual bool IsFixedSize
                        {
                                get
--- 271,275 ----
                                return array;
                        }
!       public bool IsFixedSize
                        {
                                get
***************
*** 295,299 ****
                                }
                        }
!       public virtual bool IsReadOnly
                        {
                                get
--- 278,282 ----
                                }
                        }
!       public bool IsReadOnly
                        {
                                get

Index: ArrayStack.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/ArrayStack.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** ArrayStack.cs       24 Feb 2003 10:01:00 -0000      1.4
--- ArrayStack.cs       25 Feb 2003 00:43:43 -0000      1.5
***************
*** 28,32 ****
  using System;
  
! public class ArrayStack<T> : IStack<T>, ICloneable
  {
        // Internal state.
--- 28,32 ----
  using System;
  
! public sealed class ArrayStack<T> : IStack<T>, ICloneable
  {
        // Internal state.
***************
*** 56,72 ****
                                size = 0;
                        }
-       public ArrayStack(ICollection<T> col)
-                       {
-                               if(col == null)
-                               {
-                                       throw new ArgumentNullException("col");
-                               }
-                               items = new T [col.Count];
-                               col.CopyTo(items, 0);
-                               size = items.Length;
-                       }
  
        // Implement the ICollection<T> interface.
!       public virtual void CopyTo(T[] array, int index)
                        {
                                if(array == null)
--- 56,62 ----
                                size = 0;
                        }
  
        // Implement the ICollection<T> interface.
!       public void CopyTo(T[] array, int index)
                        {
                                if(array == null)
***************
*** 88,92 ****
                                }
                        }
!       public virtual int Count
                        {
                                get
--- 78,82 ----
                                }
                        }
!       public int Count
                        {
                                get
***************
*** 95,99 ****
                                }
                        }
!       public virtual bool IsSynchronized
                        {
                                get
--- 85,89 ----
                                }
                        }
!       public bool IsSynchronized
                        {
                                get
***************
*** 102,106 ****
                                }
                        }
!       public virtual Object SyncRoot
                        {
                                get
--- 92,96 ----
                                }
                        }
!       public Object SyncRoot
                        {
                                get
***************
*** 111,115 ****
  
        // Implement the ICloneable interface.
!       public virtual Object Clone()
                        {
                                ArrayStack<T> stack = 
(ArrayStack<T>)MemberwiseClone();
--- 101,105 ----
  
        // Implement the ICloneable interface.
!       public Object Clone()
                        {
                                ArrayStack<T> stack = 
(ArrayStack<T>)MemberwiseClone();
***************
*** 119,135 ****
  
        // Implement the IIterable<T> interface.
!       public virtual IIterator<T> GetIterator()
                        {
                                return new StackIterator<T>(this);
                        }
  
!       // Clear the contents of this stack.
!       public virtual void Clear()
                        {
                                size = 0;
                        }
! 
!       // Determine if this stack contains a specific object.
!       public virtual bool Contains(T obj)
                        {
                                int index;
--- 109,123 ----
  
        // Implement the IIterable<T> interface.
!       public IIterator<T> GetIterator()
                        {
                                return new StackIterator<T>(this);
                        }
  
!       // Implement the IStack<T> interface.
!       public void Clear()
                        {
                                size = 0;
                        }
!       public bool Contains(T obj)
                        {
                                int index;
***************
*** 163,169 ****
                                return false;
                        }
! 
!       // Implement the IStack<T> interface.
!       public virtual void Push(T value)
                        {
                                if(size < items.Length)
--- 151,155 ----
                                return false;
                        }
!       public void Push(T value)
                        {
                                if(size < items.Length)
***************
*** 185,189 ****
                                }
                        }
!       public virtual T Pop()
                        {
                                if(size > 0)
--- 171,175 ----
                                }
                        }
!       public T Pop()
                        {
                                if(size > 0)
***************
*** 197,201 ****
                                }
                        }
!       public virtual T Peek()
                        {
                                if(size > 0)
--- 183,187 ----
                                }
                        }
!       public T Peek()
                        {
                                if(size > 0)
***************
*** 209,213 ****
                                }
                        }
!       public virtual T[] ToArray()
                        {
                                T[] array = new T [size];
--- 195,199 ----
                                }
                        }
!       public T[] ToArray()
                        {
                                T[] array = new T [size];
***************
*** 219,223 ****
                                return array;
                        }
!       public virtual bool IsFixedSize
                        {
                                get
--- 205,209 ----
                                return array;
                        }
!       public bool IsFixedSize
                        {
                                get
***************
*** 226,230 ****
                                }
                        }
!       public virtual bool IsReadOnly
                        {
                                get
--- 212,216 ----
                                }
                        }
!       public bool IsReadOnly
                        {
                                get

Index: FixedSizeQueue.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/FixedSizeQueue.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FixedSizeQueue.cs   24 Feb 2003 07:21:00 -0000      1.1
--- FixedSizeQueue.cs   25 Feb 2003 00:43:43 -0000      1.2
***************
*** 40,43 ****
--- 40,52 ----
  
        // Implement the IQueue<T> interface.
+       public void Clear()
+                       {
+                               throw new InvalidOperationException
+                                       (S._("NotSupp_FixedSizeCollection"));
+                       }
+       public bool Contains(T value)
+                       {
+                               return queue.Contains();
+                       }
        public void Enqueue(T value)
                        {

Index: FixedSizeStack.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/FixedSizeStack.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** FixedSizeStack.cs   24 Feb 2003 07:21:00 -0000      1.1
--- FixedSizeStack.cs   25 Feb 2003 00:43:43 -0000      1.2
***************
*** 40,43 ****
--- 40,52 ----
  
        // Implement the IStack<T> interface.
+       public void Clear()
+                       {
+                               throw new InvalidOperationException
+                                       (S._("NotSupp_FixedSizeCollection"));
+                       }
+       public bool Contains(T value)
+                       {
+                               return stack.Contains(value);
+                       }
        public void Push(T value)
                        {

Index: IQueue.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/IQueue.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** IQueue.cs   24 Feb 2003 06:56:27 -0000      1.3
--- IQueue.cs   25 Feb 2003 00:43:43 -0000      1.4
***************
*** 30,33 ****
--- 30,35 ----
  public interface IQueue<T> : ICollection<T>
  {
+       void Clear();
+       bool Contains(T value);
        void Enqueue(T value);
        T Dequeue();

Index: IStack.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/IStack.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** IStack.cs   24 Feb 2003 06:56:27 -0000      1.3
--- IStack.cs   25 Feb 2003 00:43:43 -0000      1.4
***************
*** 30,33 ****
--- 30,35 ----
  public interface IStack<T> : ICollection<T>
  {
+       void Clear();
+       bool Contains(T value);
        void Push(T value);
        T Pop();

Index: LinkedList.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/LinkedList.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** LinkedList.cs       24 Feb 2003 08:58:10 -0000      1.6
--- LinkedList.cs       25 Feb 2003 00:43:43 -0000      1.7
***************
*** 28,32 ****
  using System;
  
! public class LinkedList<T>
        : IDeque<T>, IQueue<T>, IStack<T>, IList<T>, ICloneable
  {
--- 28,32 ----
  using System;
  
! public sealed class LinkedList<T>
        : IDeque<T>, IQueue<T>, IStack<T>, IList<T>, ICloneable
  {
***************
*** 131,135 ****
  
        // Implement the IDeque<T> interface.
!       public virtual void PushFront(T value)
                        {
                                Node<T> node = new Node<T>(item);
--- 131,135 ----
  
        // Implement the IDeque<T> interface.
!       public void PushFront(T value)
                        {
                                Node<T> node = new Node<T>(item);
***************
*** 146,150 ****
                                ++count;
                        }
!       public virtual void PushBack(T value)
                        {
                                Node<T> node = new Node<T>(item);
--- 146,150 ----
                                ++count;
                        }
!       public void PushBack(T value)
                        {
                                Node<T> node = new Node<T>(item);
***************
*** 161,165 ****
                                ++count;
                        }
!       public virtual T PopFront()
                        {
                                if(first != null)
--- 161,165 ----
                                ++count;
                        }
!       public T PopFront()
                        {
                                if(first != null)
***************
*** 184,188 ****
                                }
                        }
!       public virtual T PopBack()
                        {
                                if(last != null)
--- 184,188 ----
                                }
                        }
!       public T PopBack()
                        {
                                if(last != null)
***************
*** 207,211 ****
                                }
                        }
!       public virtual T PeekFront()
                        {
                                if(first != null)
--- 207,211 ----
                                }
                        }
!       public T PeekFront()
                        {
                                if(first != null)
***************
*** 219,223 ****
                                }
                        }
!       public virtual T PeekEnd()
                        {
                                if(last != null)
--- 219,223 ----
                                }
                        }
!       public T PeekEnd()
                        {
                                if(last != null)
***************
*** 231,235 ****
                                }
                        }
!       public virtual T[] ToArray()
                        {
                                T[] array = new T [Count];
--- 231,235 ----
                                }
                        }
!       public T[] ToArray()
                        {
                                T[] array = new T [Count];
***************
*** 253,256 ****
--- 253,264 ----
  
        // Implement the IQueue<T> interface privately.
+       void IQueue<T>.Clear()
+                       {
+                               Clear();
+                       }
+       bool IQueue<T>.Contains(T value)
+                       {
+                               return Contains(value);
+                       }
        void IQueue<T>.Enqueue(T value)
                        {
***************
*** 285,288 ****
--- 293,304 ----
  
        // Implement the IStack<T> interface privately.
+       void IStack<T>.Clear()
+                       {
+                               Clear();
+                       }
+       bool IStack<T>.Contains(T value)
+                       {
+                               return Contains(value);
+                       }
        void IStack<T>.Push(T value)
                        {
***************
*** 317,321 ****
  
        // Implement the ICollection<T> interface.
!       public virtual void CopyTo(T[] array, int index)
                        {
                                IIterator<T> iterator = GetIterator();
--- 333,337 ----
  
        // Implement the ICollection<T> interface.
!       public void CopyTo(T[] array, int index)
                        {
                                IIterator<T> iterator = GetIterator();
***************
*** 325,329 ****
                                }
                        }
!       public virtual int Count
                        {
                                get
--- 341,345 ----
                                }
                        }
!       public int Count
                        {
                                get
***************
*** 332,336 ****
                                }
                        }
!       public virtual bool IsSynchronized
                        {
                                get
--- 348,352 ----
                                }
                        }
!       public bool IsSynchronized
                        {
                                get
***************
*** 339,343 ****
                                }
                        }
!       public virtual Object SyncRoot
                        {
                                get
--- 355,359 ----
                                }
                        }
!       public Object SyncRoot
                        {
                                get
***************
*** 348,352 ****
  
        // Implement the IList<T> interface.
!       public virtual int Add(T value)
                        {
                                int index = count;
--- 364,368 ----
  
        // Implement the IList<T> interface.
!       public int Add(T value)
                        {
                                int index = count;
***************
*** 354,358 ****
                                return index;
                        }
!       public virtual void Clear()
                        {
                                first = null;
--- 370,374 ----
                                return index;
                        }
!       public void Clear()
                        {
                                first = null;
***************
*** 360,364 ****
                                count = 0;
                        }
!       public virtual bool Contains(T value)
                        {
                                Node<T> current = first;
--- 376,380 ----
                                count = 0;
                        }
!       public bool Contains(T value)
                        {
                                Node<T> current = first;
***************
*** 403,411 ****
                                }
                        }
!       public virtual IListIterator<T> GetIterator()
                        {
                                return new ListIterator<T>(this);
                        }
!       public virtual int IndexOf(T value)
                        {
                                int index = 0;
--- 419,427 ----
                                }
                        }
!       public IListIterator<T> GetIterator()
                        {
                                return new ListIterator<T>(this);
                        }
!       public int IndexOf(T value)
                        {
                                int index = 0;
***************
*** 454,458 ****
                                }
                        }
!       public virtual void Insert(int index, T value)
                        {
                                if(index == count)
--- 470,474 ----
                                }
                        }
!       public void Insert(int index, T value)
                        {
                                if(index == count)
***************
*** 466,470 ****
                                }
                        }
!       public virtual void Remove(T value)
                        {
                                Node<T> current = first;
--- 482,486 ----
                                }
                        }
!       public void Remove(T value)
                        {
                                Node<T> current = first;
***************
*** 509,517 ****
                                }
                        }
!       public virtual void RemoveAt(int index)
                        {
                                Remove(Get(index));
                        }
!       public virtual bool IsFixedSize
                        {
                                get
--- 525,533 ----
                                }
                        }
!       public void RemoveAt(int index)
                        {
                                Remove(Get(index));
                        }
!       public bool IsFixedSize
                        {
                                get
***************
*** 520,524 ****
                                }
                        }
!       public virtual bool IsReadOnly
                        {
                                get
--- 536,540 ----
                                }
                        }
!       public bool IsReadOnly
                        {
                                get
***************
*** 527,531 ****
                                }
                        }
!       public virtual bool IsRandomAccess
                        {
                                get
--- 543,547 ----
                                }
                        }
!       public bool IsRandomAccess
                        {
                                get
***************
*** 534,538 ****
                                }
                        }
!       public virtual T this[int index]
                        {
                                get
--- 550,554 ----
                                }
                        }
!       public T this[int index]
                        {
                                get
***************
*** 553,557 ****
  
        // Implement the ICloneable interface.
!       public virtual Object Clone()
                        {
                                LinkedList<T> clone = new LinkedList<T>();
--- 569,573 ----
  
        // Implement the ICloneable interface.
!       public Object Clone()
                        {
                                LinkedList<T> clone = new LinkedList<T>();

Index: ReadOnlyQueue.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/ReadOnlyQueue.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ReadOnlyQueue.cs    24 Feb 2003 07:21:00 -0000      1.2
--- ReadOnlyQueue.cs    25 Feb 2003 00:43:43 -0000      1.3
***************
*** 40,43 ****
--- 40,51 ----
  
        // Implement the IQueue<T> interface.
+       public void Clear()
+                       {
+                               throw new 
InvalidOperationException(S._("NotSupp_ReadOnly"));
+                       }
+       public bool Contains(T value)
+                       {
+                               return queue.Contains();
+                       }
        public void Enqueue(T value)
                        {

Index: ReadOnlyStack.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/ReadOnlyStack.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** ReadOnlyStack.cs    24 Feb 2003 07:21:00 -0000      1.2
--- ReadOnlyStack.cs    25 Feb 2003 00:43:43 -0000      1.3
***************
*** 40,43 ****
--- 40,51 ----
  
        // Implement the IStack<T> interface.
+       public void Clear()
+                       {
+                               throw new 
InvalidOperationException(S._("NotSupp_ReadOnly"));
+                       }
+       public bool Contains(T value)
+                       {
+                               return stack.Contains(value);
+                       }
        public void Push(T value)
                        {

Index: SynchronizedQueue.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/SynchronizedQueue.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SynchronizedQueue.cs        24 Feb 2003 10:01:01 -0000      1.1
--- SynchronizedQueue.cs        25 Feb 2003 00:43:43 -0000      1.2
***************
*** 40,43 ****
--- 40,57 ----
  
        // Implement the IQueue<T> interface.
+       public void Clear()
+                       {
+                               lock(SyncRoot)
+                               {
+                                       queue.Clear();
+                               }
+                       }
+       public bool Contains(T value)
+                       {
+                               lock(SyncRoot)
+                               {
+                                       return queue.Contains();
+                               }
+                       }
        public void Enqueue(T value)
                        {

Index: SynchronizedStack.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/Generics/SynchronizedStack.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** SynchronizedStack.cs        24 Feb 2003 10:01:01 -0000      1.1
--- SynchronizedStack.cs        25 Feb 2003 00:43:43 -0000      1.2
***************
*** 40,43 ****
--- 40,57 ----
  
        // Implement the IStack<T> interface.
+       public void Clear()
+                       {
+                               lock(SyncRoot)
+                               {
+                                       stack.Clear();
+                               }
+                       }
+       public bool Contains(T value)
+                       {
+                               lock(SyncRoot)
+                               {
+                                       return stack.Contains(value);
+                               }
+                       }
        public void Push(T value)
                        {





reply via email to

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