/** * Appends the specified element to the end of this list. * * @param o element to be appended to this list. * @return <tt>true</tt> (as per the general contract of Collection.add). */ @Override public boolean add(Long o) { return add(o.longValue()); }
/** * Inserts the specified element at the specified position in this * list. Shifts the element currently at that position (if any) and * any subsequent elements to the right (adds one to their indices). * * @param index index at which the specified element is to be inserted. * @param element element to be inserted. * @throws IndexOutOfBoundsException if index is out of range * <tt>(index < 0 || index > size())</tt>. */ @Override public void add(int index, Long element) { add(index, element.longValue()); }
/** * Adds the specified element in sorted position within this list. * * @param o element to be appended to this list. * @return <tt>true</tt> (as per the general contract of Collection.add). */ @Override public boolean add(long o) { // Shortcut for empty int mySize=size(); if(mySize==0) { super.add(o); } else { // Shortcut for adding to end (makes imports of already-sorted data operate at constant-time instead of logarithmic complexity) if(o>=elementData[mySize-1]) { super.add(o); } else { int index=binarySearch(o); if(index<0) { // Not found in list super.add(-(index+1), o); } else { // Add after existing super.add(index+1, o); } } } return true; }