I have a queue of users(string of emails) a in c# and I want to send the user his location in this queue.
something like ;
Queue q = new Queue(32);
q.Enqueue(Session["email"].ToString());
queue.IndexOf(email);
Any ideas?
thanks
In an Indexed Priority Queue, data is stored just like standard priority queue and along with this, the value of a data can be updated using its key. It is called “indexed” because a hash map can be used to store the index in container using the key of key-value pair input as the key of hash map.
It is used when you need a first-in, first-out access of items. When you add an item in the list, it is called enqueue, and when you remove an item, it is called deque. Queue . Contains(T) Method is used to check whether an element is in the Queue .
Count Property is used to get the number of elements contained in the Queue. Properties: Enqueue adds an element to the end of the Queue. Dequeue removes the oldest element from the start of the Queue.
To obtain the first element and the last element in the queue, the most straightforward way is to use indices. The first element in the queue has an index of 0. For the last item in the queue, we can use the -1 index. The minus sign indicates to Python to start counting items backward from the end of the queue.
Maybe a List
or an Array
would be better for such actions but you could try this:
queue.ToArray().ToList().IndexOf(email);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With