@Test
  public void testShuffled() {

    for (Integer[] perm : perms) {
      Group group = new Group("group");

      for (Integer i : perm) {
        Item item = new Item(group, i);
        group.add(item);
      }

      Queueable[] elems = group.getQueue();
      for (Queueable elem : elems) {
        Item item = (Item) elem;
        //        System.out.print( " " + item.getSalience() + "/"  + item.getActivationNumber() +
        // "/" + item.getIndex() );
        if (item.getIndex() % 2 == 0) {
          group.remove(item);
          group.add(item);
        }
      }
      boolean ok = true;
      StringBuilder sb = new StringBuilder("queue:");
      for (int i = max - 1; i >= 0; i--) {
        int sal = group.getNext().getSalience();
        sb.append(" ").append(sal);
        if (sal != i) ok = false;
      }
      assertTrue("incorrect order in " + sb.toString(), ok);
      //      System.out.println( sb.toString() );
    }
  }
    public final int compare(final Item existing, final Item adding) {
      final int s1 = existing.getSalience();
      final int s2 = adding.getSalience();

      if (s1 != s2) {
        return s1 - s2;
      }

      // we know that no two activations will have the same number
      return (int) (existing.getActivationNumber() - adding.getActivationNumber());
    }
 public void remove(Item agendaItem) {
   this.queue.dequeue(agendaItem.getIndex());
 }