protected int insert(SpdData elt) {
        if (members.isEmpty()) {
            members.add(elt);
            return 0;
        }

        int first = 0;
        SpdData firstElt = (SpdData) members.get(first);
        int last = members.size() - 1;
        SpdData lastElt = (SpdData) members.get(last);

        if (elt.compareTo(firstElt) < 0) {
            members.add(first, elt);
            return first;
        } else if (elt.compareTo(lastElt) > 0) {
            members.add(last + 1, elt);
            return last + 1;
        }
        while (last > (first + 1)) {
            int middle = (first + last) / 2;
            SpdData midElt = (SpdData) members.get(middle);

            if (midElt.compareTo(elt) > 0) {
                last = middle;
                lastElt = midElt;
            } else {
                first = middle;
                firstElt = midElt;
            }
        }
        if ((elt.compareTo(firstElt) == 0) ||
            (elt.compareTo(lastElt) == 0)) {
            return -1;
        } else {
            members.add(last, elt);
            return last;
        }
    }
protected int insert ( SpdData elt ) { if ( members . isEmpty ( ) ) { members . add ( elt ) ; return 0 ; } int first = 0 ; SpdData firstElt = ( SpdData ) members . get ( first ) ; int last = members . size ( ) - 1 ; SpdData lastElt = ( SpdData ) members . get ( last ) ; if ( elt . compareTo ( firstElt ) < 0 ) { members . add ( first , elt ) ; return first ; } else if ( elt . compareTo ( lastElt ) > 0 ) { members . add ( last + 1 , elt ) ; return last + 1 ; } while ( last > ( first + 1 ) ) { int middle = ( first + last ) / 2 ; SpdData midElt = ( SpdData ) members . get ( middle ) ; if ( midElt . compareTo ( elt ) > 0 ) { last = middle ; lastElt = midElt ; } else { first = middle ; firstElt = midElt ; } } if ( ( elt . compareTo ( firstElt ) == 0 ) || ( elt . compareTo ( lastElt ) == 0 ) ) { return - 1 ; } else { members . add ( last , elt ) ; return last ; } }
Insert the element into the members vector in sorted
lexicographical order