public void add(E element)
    {
        arrayList.add(element);
        int child = arrayList.size() - 1;
        while (child > 0)
        {
            int parent = (child - 1) / 2;
            int comparison = arrayList.get(parent).compareTo(arrayList.get(child));
            if ((maximum && comparison >= 0) || (!maximum && comparison <= 0))
            {
                break;
            }
            swap(parent, child);
            child = parent;
        }
    }