/// <summary>Initialize the priority queue.</summary> /// <param name="queue">The queue to be synchronized.</param> internal ChoSyncPriorityQueue(ChoPriorityQueue queue) { // NOTE: We're synchronizing just be using a synchronized heap! // This implementation will need to change if we get more state. if (!(_heap is ChoBinaryHeap.ChoSyncBinaryHeap)) { _heap = ChoBinaryHeap.Synchronize(_heap); } }
/// <summary>Ensures that heap is wrapped in a synchronous wrapper.</summary> /// <param name="heap">The heap to be wrapped.</param> /// <returns>A synchronized wrapper for the heap.</returns> public static ChoBinaryHeap Synchronize(ChoBinaryHeap heap) { // Create a synchronization wrapper around the heap and return it. if (heap is ChoSyncBinaryHeap) { return(heap); } return(new ChoSyncBinaryHeap(heap)); }
/// <summary>Initialize the queue.</summary> /// <param name="queue">The queue is intialized with a shalled-copy of this queue.</param> public ChoPriorityQueue(ChoPriorityQueue queue) { _heap = queue._heap.Clone(); }
/// <summary>Initialize the queue.</summary> public ChoPriorityQueue() { _heap = new ChoBinaryHeap(); }
/// <summary>Initialize the synchronized heap.</summary> /// <param name="heap">The heap to synchronize.</param> internal ChoSyncBinaryHeap(ChoBinaryHeap heap) { _heap = heap; }
/// <summary>Initialize the heap with another heap.</summary> /// <param name="heap">The heap on which to perform a shallow-copy.</param> public ChoBinaryHeap(ChoBinaryHeap heap) { // Clone the list (the only state we have) _list = (ArrayList)heap._list.Clone(); }