Main Page | Class Hierarchy | Class List | File List | Class Members

Queue.cs

00001 using System;
00002 using System.Collections;
00003 
00004 namespace GPRSWeb.SmartDeviceClient.Common
00005 {
00009         public class Queue : ICollection, IEnumerable, ICloneable
00010         {       
00011 
00012                 private ArrayList myList;
00013 
00014                 public Queue() {
00015                         myList = new ArrayList();
00016                 }
00017 
00018                 public virtual void Enqueue(object o) {
00019                         myList.Add(o);
00020                 }
00021 
00022                 public void Clear() {
00023                         myList.Clear();
00024                 }
00025                 public virtual object Dequeue() {
00026                         object result = myList[0];
00027                         myList.RemoveAt(0);
00028                         return result;
00029                 }
00030 
00031                 public object SyncRoot {
00032                         get { return myList.SyncRoot; }
00033                 }
00034 
00035                 public bool IsSynchronized {
00036                         get { return myList.IsSynchronized; }
00037                 }
00038 
00039                 public void CopyTo(Array array, int index) {
00040                         if (array == null) { throw new ArgumentNullException("array"); } 
00041                         else if (index < 0) { throw new ArgumentOutOfRangeException("Index should not be less than zero");}
00042                         else if (array.Rank != 1 || index >= array.Length || myList.Count > (array.Length - index)) { throw new ArgumentException(); }
00043                         else {
00044                                 for (int i = index, j = 0; i < myList.Count; i++, j++) {
00045                                         array.SetValue(myList[j], i);
00046                                 }
00047                         }
00048                 }
00049 
00050                 public int Count {
00051                         get { return myList.Count; }
00052                 }
00053 
00054                 public IEnumerator GetEnumerator() {
00055                         return myList.GetEnumerator();
00056                 }
00057 
00058                 public object Clone() {
00059                         Queue result = new Queue();
00060                         result.myList = (ArrayList)myList.Clone();
00061                         return result;
00062                 }
00063 
00064         }
00065 }

Generated on Mon May 8 22:07:27 2006 by  doxygen 1.3.9.1