Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is one very important point you've not mentioned in your question, and that is whether your queue of items is <strong>sorted</strong> or have some kind of <strong>ordering</strong> (called a <a href="http://en.wikipedia.org/wiki/Priority_queue" rel="nofollow">Priority queue</a>), or <strong>unsorted</strong> (called a plain FIFO). The solution you choose will depend only on the answer to this question.</p> <ol> <li><p><em>If your queue is unsorted</em>, then maintaining an extra data structure in addition to your queue will be more efficient. Using a second structure which is ordered in some way to maintain the contents of your queue will allow you check if an item already exists in your queue or not much quicker that scanning the queue itself. Adding to the end of an unsorted queue takes constant time and can be done very efficiently.</p></li> <li><p><em>If your queue must be sorted</em>, then placing the item into the queue requires you to know the item's <strong>position</strong> in the queue, which requires the queue to be scanned anyway. Once you know an item's position, you know if the item is a duplicate because if it's a duplicate then an item will already exist at that position in the queue. In this case, all work can be performed optimally on the queue itself and maintaining any secondary data structure is unnecessary.</p></li> </ol> <p>The choice of data structures is up to you. However, for (1) the secondary data structure should <em>not</em> be any kind of list or array, otherwise it will be no more efficient to scan your secondary index as to scan the original queue itself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload