@Override
    public String toString() {
        return Stream.of( elements ).filter(Objects::nonNull).collect(toList() ).toString();
    }
@Test
    public void testShuffled() {

        long time = System.currentTimeMillis();
        for (int k = 0; k < 10; k++) {
            for (Integer[] perm : perms) {
                Group group = new Group("group");

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

                InternalMatch[] elems = group.getQueue().toArray(new InternalMatch[0]);
                for (InternalMatch elem : elems) {
                    Item item = (Item) elem;
                    //        System.out.print( " " + item.getSalience() + "/"  + item.getActivationNumber() + "/" + item.getQueueIndex() );
                    if (item.getQueueIndex() % 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;
                    }
                }
                assertThat(ok).as("incorrect order in " + sb.toString()).isTrue();
                //      System.out.println( sb.toString() );
            }
        }
        System.out.println("time:" + (System.currentTimeMillis() - time));
    }