public static IDeque Subdeque(IDeque a, int start, int length) { IDeque newDeque = (IDeque)Activator.CreateInstance(a.GetType()); for (int i = start; i < start + length; ++i) { newDeque.Add(a[i]); } return(newDeque); }
public static IDeque ConcatenateIDeque(IDeque a, IDeque b) { // create new deque as a copy of a IDeque newDeque = (IDeque)Activator.CreateInstance(a.GetType(), a); // then append b foreach (object entry in b) { newDeque.Enqueue(entry); } return(newDeque); }
public static IDeque Copy(IDeque deque, IGraph graph, IDictionary <IBaseObject, IBaseObject> oldToNewObjects) { IDeque copy = (IDeque)Activator.CreateInstance(deque.GetType()); foreach (object element in deque) { if (element is IObject) { IObject elem = (IObject)element; copy.Add(elem.Copy(graph, oldToNewObjects)); } else if (element is ITransientObject) { ITransientObject elem = (ITransientObject)element; copy.Add(elem.Copy(graph, oldToNewObjects)); } else { copy.Add(element); } } return(copy); }