Make new Index inserting new item at location.

        Follows Python list.append semantics for negative values.

        Parameters
        ----------
        loc : int
        item : object

        Returns
        -------
        new_index : Index
541645
def insert(self, loc, item):
        
        _self = np.asarray(self)
        item = self._coerce_scalar_to_index(item)._ndarray_values
        idx = np.concatenate((_self[:loc], item, _self[loc:]))
        return self._shallow_copy_with_infer(idx)
1311634
def insert(self, iterable, data=None, weight=1.0):
        
        self.root.insert(iterable, index=0, data=data, weight=1.0)
342033
function add(item, index) {
      if (!item) return -1;

      if (!angular.isNumber(index)) {
        index = _items.length;
      }

      _items.splice(index, 0, item);

      return indexOf(item);
    }
682972
public Element put(int index, Element newValue) {

		Element oldValue = null;

        int size = list.size();

		if (index < 0) {
            if (index < -size) {
                // negative indices do not auto-prepend
                // (asopposed to positive ones that grow the list by appending undef)
                throw new EvaluationException(MessageUtils.format(
                    MSG_INVALID_NEGATIVE_LIST_INDEX, Integer.toString(index), size));
            } else {
                index += size;
            }
		}

		try {
			if ((newValue != null) && !(newValue instanceof Null)) {
				if (index >= size) {
					for (int i = 0; i < index - size; i++) {
						list.add(Undef.VALUE);
					}
					list.add(newValue);
				} else {
					oldValue = list.set(index, newValue);
					if (oldValue != null) {
						oldValue.checkValidReplacement(newValue);
					}
				}
			} else {
				try {
					oldValue = list.remove(index);
				} catch (IndexOutOfBoundsException ioobe) {
					// Ignore this error; removing non-existant element is OK.
				}
			}
		} catch (IndexOutOfBoundsException ioobe) {
			throw new EvaluationException(MessageUtils.format(
					MSG_NONEXISTANT_LIST_ELEMENT, Integer.toString(index)));
		}
		return oldValue;
	}
553180
def insert(self, loc, column, value):
        
        if is_list_like(value):
            # TODO make work with another querycompiler object as `value`.
            # This will require aligning the indices with a `reindex` and ensuring that
            # the data is partitioned identically.
            if isinstance(value, pandas.Series):
                value = value.reindex(self.index)
            value = list(value)

        def insert(df, internal_indices=[]):
            internal_idx = int(internal_indices[0])
            old_index = df.index
            df.index = pandas.RangeIndex(len(df.index))
            df.insert(internal_idx, internal_idx, value, allow_duplicates=True)
            df.columns = pandas.RangeIndex(len(df.columns))
            df.index = old_index
            return df

        new_data = self.data.apply_func_to_select_indices_along_full_axis(
            0, insert, loc, keep_remaining=True
        )
        new_columns = self.columns.insert(loc, column)
        return self.__constructor__(new_data, self.index, new_columns)
600236
def insert(self, item, priority):
        """"""

        with self.lock:

            self_data = self.data
            rotate = self_data.rotate
            self_items = self.items
            maxlen = self._maxlen

            try:

                if priority <= self_data[-1][1]:
                    self_data.append((item, priority))
                elif priority > self_data[0][1]:
                    self_data.appendleft((item, priority))
                else:

                    length = len(self_data) + 1
                    mid = length // 2
                    shift = 0

                    while True:

                        if priority <= self_data[0][1]:
                            rotate(-mid)
                            shift += mid
                            mid //= 2
                            if mid == 0:
                                mid += 1

                        else:
                            rotate(mid)
                            shift -= mid
                            mid //= 2
                            if mid == 0:
                                mid += 1

                        if self_data[-1][1] >= priority > self_data[0][1]:
                            self_data.appendleft((item, priority))

                            # When returning to original position, never shift
                            # more than half length of DEPQ i.e. if length is
                            # 100 and we rotated -75, rotate -25, not 75
                            if shift > length // 2:
                                shift = length % shift
                                rotate(-shift)
                            else:
                                rotate(shift)

                            break

                try:
                    self_items[item] += 1
                except TypeError:
                    self_items[repr(item)] += 1

            except IndexError:
                self_data.append((item, priority))
                try:
                    self_items[item] = 1
                except TypeError:
                    self_items[repr(item)] = 1

            if maxlen is not None and maxlen < len(self_data):
                self._poplast()
1259297
def Append(self, item):
    
    if self._index >= self._size:
      self._index = self._index % self._size

    try:
      self._list[self._index] = item
    except IndexError:
      self._list.append(item)
    self._index += 1
1069045
def create_and_add(self, key, value=None, cas=0, **options):
        
        itm = Item(key, value)
        itm.cas = cas
        return self.add(itm, **options)
349186
function insertAt(items, item, index) {
  var copy = items.slice();
  copy.splice(index, 0, item);
  return copy;
}
885092
def insert(self, index, item):
        # type: (int, Any) -> None
        
        return list.insert(self, index, self.ref(item))
1326668
def insert(self, index, p_object):
        
        key = self._get_object_key(p_object)
        if key in self._col_dict:
            raise KeyError()
        self._col_list.insert(index, p_object)
        self._col_dict[key] = p_object
1336750
def add(self, key, val):
        
        key_lower = key.lower()
        new_vals = key, val
        # Keep the common case aka no item present as fast as possible
        vals = _dict_setdefault(self, key_lower, new_vals)
        if new_vals is not vals:
            # new_vals was not inserted, as there was a previous one
            if isinstance(vals, list):
                # If already several items got inserted, we have a list
                vals.append(val)
            else:
                # vals should be a tuple then, i.e. only one item so far
                # Need to convert the tuple to list for further extension
                _dict_setitem(self, key_lower, [vals[0], vals[1], val])
1261611
def append(self, item):
        
        with self.lock:
            with self._closeable_cursor() as cursor:
                cursor.execute('''INSERT INTO list (list_index, value) VALUES ((SELECT MAX(list_index) FROM list) + 1, ?)''', (self._coder(item), ) )
            self._do_write()
135001
def binary_insert(self, item, priority):
    """"""

    with self.lock:
        self_data = self.data
        rotate = self_data.rotate
        maxlen = self._maxlen
        length = len(self_data)

        index = 0
        min = 0
        max = length - 1

        while max - min > 10:

            mid = (min + max) // 2

            # If index in 1st half of list
            if priority > self_data[mid][1]:
                max = mid - 1

            # If index in 2nd half of list
            else:
                min = mid + 1

        for i in range(min, max + 1):
            if priority > self_data[i][1]:
                index = i
                break
            elif i == max:
                index = max + 1

        shift = length - index

        # Never shift more than half length of depq
        if shift > length // 2:
            shift = length % shift
            rotate(-shift)
            self_data.appendleft((item, priority))
            rotate(shift)
        else:
            rotate(shift)
            self_data.append((item, priority))
            rotate(-shift)

        try:
            self.items[item] += 1
        except TypeError:
            self.items[repr(item)] += 1

        if maxlen is not None and maxlen < len(self_data):
                self._poplast()
520372
def insertItem(self, childItem, position=None, parentIndex=None):
        
        if parentIndex is None:
            parentIndex=QtCore.QModelIndex()

        parentItem = self.getItem(parentIndex, altItem=self.invisibleRootItem)

        nChildren = parentItem.nChildren()
        if position is None:
            position = nChildren

        assert 0 <= position <= nChildren, \
            "position should be 0 < {} <= {}".format(position, nChildren)

        self.beginInsertRows(parentIndex, position, position)
        try:
            parentItem.insertChild(childItem, position)
        finally:
            self.endInsertRows()

        childIndex = self.index(position, 0, parentIndex)
        assert childIndex.isValid(), "Sanity check failed: childIndex not valid"
        return childIndex
649003
def insert(self, key, value, data={}):
        
        if value < self.min_value or value > self.max_value:
            raise BoundsError('item value out of bounds')

        item = self.Item(key, value, data)
        index = self.get_bin_index(value)

        self.bins[index].append(item)
1336356
def create_index(self, key, reindex=True, sparse=False):
        
        warnings.warn('Index support is currently very alpha and is not guaranteed')
        if isinstance(key, (list, tuple)):
            index_name = ','.join(key)
            index_columns = ', '.join('%s text' % f for f in key)
        else:
            index_name = key
            index_columns = '%s text' % key

        table_name = '[%s{%s}]' % (self.name, index_name)
        reindex = reindex or not self._object_exists('table', table_name)

        # Create a table store for the index data
        self.db.execute("""
            create table if not exists {table} (
                id integer primary key,
                {columns},
                foreign key(id) references {collection}(id) on delete cascade on update cascade
            )
        """.format(
            table=table_name,
            collection=self.name,
            columns=index_columns
        ))

        # Create the index
        self.db.execute("""
            create index if not exists [idx.{collection}{{index}}] on {table}({index})
        """.format(
            collection=self.name,
            index=index_name,
            table=table_name,
        ))

        if reindex:
            self.reindex(key)