public PriorityQueue()
 {
     size         = 0;
     priorityList = new SingleArray <Queue <T> >();
     priorityList.Add(new Queue <T>(), 0);
     priorityList.Add(new Queue <T>(), 1);
     priorityList.Add(new Queue <T>(), 2);
 }
        public void Enqueue(T item, int priority)
        {
            if (priority > priorityList.Size() || priorityList.Get(priority) == null)
            {
                priorityList.Add(new Queue <T>(), priority);
            }

            priorityList.Get(priority).Enqueue(item);
            size += 1;
        }
Exemplo n.º 3
0
        public void Add(T item)
        {
            if (size == array.Size() * vector)
            {
                array.Add(new VectorArray <T>(vector));
            }

            int index = Size();

            if (array.Get(index / vector) != null)
            {
                array.Get(index / vector).Add(item);
                size += 1;
            }
            else
            {
                array.Add(new VectorArray <T>(vector), index / vector);
                array.Get(index / vector).Add(item);
            }
        }