public boolean offer(E o)
    {
        // Make a new node out of the new data element.
        Node newNode = new Node(o);

        // Check if there is already a minimum element.
        if (minNode != null)
        {
            // There is already a minimum element, so add this new element to its right.
            newNode.next = minNode.next;
            newNode.prev = minNode;

            minNode.next.prev = newNode;
            minNode.next = newNode;

            // Compare the new element with the minimum and update the minimum if neccessary.
            updateMinimum(newNode);
        }

        // There is not already a minimum element.
        else
        {
            // Update the new element previous and next references to refer to itself so that it forms a doubly linked
            // list with only one element. This leaves the data structure in a suitable condition for adding more
            // elements.
            newNode.next = newNode;
            newNode.prev = newNode;

            // Set the minimum element to be the new data element.
            minNode = newNode;
        }

        // Increment the count of data elements in this collection.
        size++;

        // Return true to indicate that the new data element was accepted into the heap.
        return true;
    }
public boolean offer(E o)
    {
        
        Node newNode = new Node(o);

        
        if (minNode != null)
        {
            
            newNode.next = minNode.next;
            newNode.prev = minNode;

            minNode.next.prev = newNode;
            minNode.next = newNode;

            
            updateMinimum(newNode);
        }

        
        else
        {
            
            
            
            newNode.next = newNode;
            newNode.prev = newNode;

            
            minNode = newNode;
        }

        
        size++;

        
        return true;
    }
public boolean offer ( E o ) { // Make a new node out of the new data element. Node newNode = new Node ( o ) ; // Check if there is already a minimum element. if ( minNode != null ) { // There is already a minimum element, so add this new element to its right. newNode . next = minNode . next ; newNode . prev = minNode ; minNode . next . prev = newNode ; minNode . next = newNode ; // Compare the new element with the minimum and update the minimum if neccessary. updateMinimum ( newNode ) ; } // There is not already a minimum element. else { // Update the new element previous and next references to refer to itself so that it forms a doubly linked // list with only one element. This leaves the data structure in a suitable condition for adding more // elements. newNode . next = newNode ; newNode . prev = newNode ; // Set the minimum element to be the new data element. minNode = newNode ; } // Increment the count of data elements in this collection. size ++ ; // Return true to indicate that the new data element was accepted into the heap. return true ; }
Inserts the specified element into this heap.

@param  o The data element to add to the heap.

@return True if it was succesfully added, false if not. (This implmentation always returns true).86
Inserts the specified element into this heap .