public List<T> toList() {
        List<T> result = new LinkedList<>();
        for (int i = 0; i < size; i++) {
            result.add((T) elements[i]);
        }
        return result;
    }
@Test
    void testOfferMoreThanSizeWithShuffle() {
        List<Integer> testCase = new ArrayList<>(50);
        for (int i = 0; i < 50; i++) {
            testCase.add(i);
        }
        Collections.shuffle(testCase);
        FixedSizePriorityQueue<Integer> queue = new FixedSizePriorityQueue<>(10, Comparator.<Integer>naturalOrder());
        testCase.forEach(queue::offer);
        List<Integer> list = queue.toList();
        assertEquals(10, list.size());
        for (int i = 49; i > 39; i--) {
            assertTrue(list.contains(i));
        }
    }