Inserts a new entry into the heap and returns the entry if heap is not full. Returns absent otherwise.
No heap consolidation is performed.
Runtime: O(1)
327390
public Entry add(V value, P priority) {
        Preconditions.checkNotNull(value);
        Preconditions.checkNotNull(priority);

        if (size >= MAX_CAPACITY) return null;

        final Entry result = new Entry(value, priority);
        // add as a root
        oMinEntry = mergeLists(result, oMinEntry);
        size++;

        return result;
    }
164486
def push(self, el):
        
        count = next(self.counter)
        heapq.heappush(self._queue, (el, count))
1052385
@Override
    @SuppressWarnings("unchecked")
    @ConstantTime(amortized = true)
    public AddressableHeap.Handle<K, V> insert(K key, V value) {
        if (other != this) {
            throw new IllegalStateException("A heap cannot be used after a meld");
        }
        if (key == null) {
            throw new NullPointerException("Null keys not permitted");
        }

        Node<K, V> n = new Node<K, V>(this, key, value);
        if (root == null) {
            root = n;
        } else {
            if (comparator == null) {
                if (((Comparable<? super K>) n.key).compareTo(root.key) < 0) {
                    root = link(root, n);
                } else {
                    link(n, root);
                }
            } else {
                if (comparator.compare(n.key, root.key) < 0) {
                    root = link(root, n);
                } else {
                    link(n, root);
                }
            }
        }
        size++;
        return n;
    }
409971
def heapify(self, key=__marker):
        
        if key is self.__marker:
            n = len(self._heap)
            for pos in reversed(range(n//2)):
                self._sink(pos)
        else:
            try:
                pos = self._position[key]
            except KeyError:
                raise KeyError(key)
            self._reheapify(pos)
223284
@Override
    @ConstantTime(amortized = true)
    public AddressableHeap.Handle<K, V> insert(K key, V value) {
        if (other != this) {
            throw new IllegalStateException("A heap cannot be used after a meld");
        }
        if (key == null) {
            throw new NullPointerException("Null keys not permitted");
        }
        Node<K, V> n = new Node<K, V>(this, key, value);
        addToRootList(n);
        size++;
        return n;
    }
832772
protected Entry<K, V> insertNewEntry(K key, int hc, int val) {
    Entry<K,V> e = new Entry<K,V>(extractIntKeyObj(key), val);
    Entry<K, V> e2;
    final OptimisticLock l = hash.getSegmentLock(hc);
    final long _stamp = l.writeLock();
    boolean _needsEviction = false;
    try {
      e2 = hash.insertWithinLock(e, hc, val);
      if (e == e2) {
        _needsEviction = eviction.submitWithoutEviction(e);
      }
    } finally {
      l.unlockWrite(_stamp);
    }
    if (_needsEviction) {
      eviction.evictEventually(hc);
    }
    hash.checkExpand(hc);
    return e2;
  }
961297
def add(self, value):
        
        ind = int(self._ind % self.shape)
        self._pos = self._ind % self.shape
        self._values[ind] = value
        if self._ind < self.shape:
            self._ind += 1  # fast fill
        else:
            self._ind += self._splitValue
            self._splitPos += self._splitValue
        self._cached = False
463525
def get_heap(self, *args, **kwargs):
        
        heap = Heap(self._flavour)
        self.add_to_heap(heap, *args, **kwargs)
        return heap
132130
private void writeEntry(HashtableEntry entry)

    throws IOException, EOFException, FileManagerException, ClassNotFoundException {

        long index = getHtindex(entry.index, entry.tableid);
        if (index == 0) { // first one in this bucket
            updateEntry(entry); // write to disk
            writeHashIndex(entry.index, entry.location, entry.tableid); // update index
        } else if (index == entry.location) { // replacing first entry
            updateEntry(entry);
            writeHashIndex(entry.index, entry.location, entry.tableid); // update index
        } else { // 
            //
            // If the entry has a "previous" pointer, then it was read earlier
            // from disk.  Otherwise, it is a brand new entry.  If it is a brand
            // entry, we write it to disk and chain at the front of the bucket.
            // If "previous" is not zero, we check to see if reallocation is
            // needed (location == 0).  If not, we simply update on disk and we're
            // done.  If reallocation is needed we update on disk to do the allocation
            // and call updatePointer to chain into the bucket.
            //
            if (entry.previous == 0) {
                entry.next = index;
                updateEntry(entry);
                writeHashIndex(entry.index, entry.location, entry.tableid); // update index
            } else {
                if (entry.location == 0) { // allocation needed?
                    updateEntry(entry); // do allocation
                    updatePointer(entry.previous, entry.location); // chain in
                } else {
                    updateEntry(entry); // no allocation, just update fields
                }
            }
        }

    }
710547
@Override
  protected void preInsert(MkMaxEntry entry) {
    KNNHeap knns_o = DBIDUtil.newHeap(getKmax());
    preInsert(entry, getRootEntry(), knns_o);
  }
1151369
def push(self, record, shard):
        
        heapq.heappush(self.heap, heap_item(self.clock, record, shard))
1197834
def addEntry(self, key='', value=''):
        
        img = resources.find('img/close.png')
        new_item = XTreeWidgetItem()
        new_item.setText(1, nativestring(key))
        new_item.setText(2, nativestring(value))
        new_item.setIcon(0, QtGui.QIcon(img))
        new_item.setFixedHeight(22)
        self.insertTopLevelItem(self.topLevelItemCount() - 1, new_item)
        
        return new_item
1072838
public void putNextEntry(TarEntry entry) throws IOException {
        closeCurrentEntry();

        byte[] header = new byte[TarConstants.HEADER_BLOCK];
        entry.writeEntryHeader( header );

        write( header );

        currentEntry = entry;
    }
656543
private Entry<K, V> returnEntry(final Entry<K, V> e) {
    touchEntry(e.getKey());
    return e;
  }
552439
protected <E extends RaftLogEntry> CompletableFuture<Indexed<E>> appendAndCompact(E entry, int attempt) {
    if (attempt == MAX_APPEND_ATTEMPTS) {
      return Futures.exceptionalFuture(new StorageException.OutOfDiskSpace("Not enough space to append entry"));
    } else {
      try {
        return CompletableFuture.completedFuture(raft.getLogWriter().append(entry))
            .thenApply(indexed -> {
              log.trace("Appended {}", indexed);
              return indexed;
            });
      } catch (StorageException.TooLarge e) {
        return Futures.exceptionalFuture(e);
      } catch (StorageException.OutOfDiskSpace e) {
        log.warn("Caught OutOfDiskSpace error! Force compacting logs...");
        return raft.getServiceManager().compact().thenCompose(v -> appendAndCompact(entry, attempt + 1));
      }
    }
  }
1127550
def NewMemory(self, buffer, size, URL, encoding, options):
        
        ret = libxml2mod.xmlReaderNewMemory(self._o, buffer, size, URL, encoding, options)
        return ret
311312
public Entry<T> dequeueMin() {
        /* Check for whether we're empty. */
        if (isEmpty())
            throw new NoSuchElementException("Heap is empty.");

        /* Otherwise, we're about to lose an element, so decrement the number of
         * entries in this heap.
         */
        --mSize;

        /* Grab the minimum element so we know what to return. */
        Entry<T> minElem = mMin;

        /* Now, we need to get rid of this element from the list of roots.  There
         * are two cases to consider.  First, if this is the only element in the
         * list of roots, we set the list of roots to be null by clearing mMin.
         * Otherwise, if it's not null, then we write the elements next to the
         * min element around the min element to remove it, then arbitrarily
         * reassign the min.
         */
        if (mMin.mNext == mMin) { // Case one
            mMin = null;
        } else { // Case two
            mMin.mPrev.mNext = mMin.mNext;
            mMin.mNext.mPrev = mMin.mPrev;
            mMin = mMin.mNext; // Arbitrary element of the root list.
        }

        /* Next, clear the parent fields of all of the min element's children,
         * since they're about to become roots.  Because the elements are
         * stored in a circular list, the traversal is a bit complex.
         */
        if (minElem.mChild != null) {
            /* Keep track of the first visited node. */
            Entry<?> curr = minElem.mChild;
            do {
                curr.mParent = null;

                /* Walk to the next node, then stop if this is the node we
                 * started at.
                 */
                curr = curr.mNext;
            } while (curr != minElem.mChild);
        }

        /* Next, splice the children of the root node into the topmost list,
         * then set mMin to point somewhere in that list.
         */
        mMin = mergeLists(mMin, minElem.mChild);

        /* If there are no entries left, we're done. */
        if (mMin == null) return minElem;

        /* Next, we need to coalsce all of the roots so that there is only one
         * tree of each degree.  To track trees of each size, we allocate an
         * ArrayList where the entry at position i is either null or the
         * unique tree of degree i.
         */
        List<Entry<T>> treeTable = new ArrayList<Entry<T>>();

        /* We need to traverse the entire list, but since we're going to be
         * messing around with it we have to be careful not to break our
         * traversal order mid-stream.  One major challenge is how to detect
         * whether we're visiting the same node twice.  To do this, we'll
         * spent a bit of overhead adding all of the nodes to a list, and
         * then will visit each element of this list in order.
         */
        List<Entry<T>> toVisit = new ArrayList<Entry<T>>();

        /* To add everything, we'll iterate across the elements until we
         * find the first element twice.  We check this by looping while the
         * list is empty or while the current element isn't the first element
         * of that list.
         */
        for (Entry<T> curr = mMin; toVisit.isEmpty() || toVisit.get(0) != curr; curr = curr.mNext)
            toVisit.add(curr);

        /* Traverse this list and perform the appropriate unioning steps. */
        for (Entry<T> curr : toVisit) {
            /* Keep merging until a match arises. */
            while (true) {
                /* Ensure that the list is long enough to hold an element of this
                 * degree.
                 */
                while (curr.mDegree >= treeTable.size())
                    treeTable.add(null);

                /* If nothing's here, we're can record that this tree has this size
                 * and are done processing.
                 */
                if (treeTable.get(curr.mDegree) == null) {
                    treeTable.set(curr.mDegree, curr);
                    break;
                }

                /* Otherwise, merge with what's there. */
                Entry<T> other = treeTable.get(curr.mDegree);
                treeTable.set(curr.mDegree, null); // Clear the slot

                /* Determine which of the two trees has the smaller root, storing
                 * the two tree accordingly.
                 */
                Entry<T> min = (other.mPriority < curr.mPriority) ? other : curr;
                Entry<T> max = (other.mPriority < curr.mPriority) ? curr : other;

                /* Break max out of the root list, then merge it into min's child
                 * list.
                 */
                max.mNext.mPrev = max.mPrev;
                max.mPrev.mNext = max.mNext;

                /* Make it a singleton so that we can merge it. */
                max.mNext = max.mPrev = max;
                min.mChild = mergeLists(min.mChild, max);

                /* Reparent max appropriately. */
                max.mParent = min;

                /* Clear max's mark, since it can now lose another child. */
                max.mIsMarked = false;

                /* Increase min's degree; it now has another child. */
                ++min.mDegree;

                /* Continue merging this tree. */
                curr = min;
            }

            /* Update the global min based on this node.  Note that we compare
             * for <= instead of < here.  That's because if we just did a
             * reparent operation that merged two different trees of equal
             * priority, we need to make sure that the min pointer points to
             * the root-level one.
             */
            if (curr.mPriority <= mMin.mPriority) mMin = curr;
        }
        return minElem;
    }