// insert places the provided stat in the appropriate current, previous, or future bucket.
// It returns an error if the stat could not be placed in a bucket
344239
func (b *Bucketer) insert(s *stat.Stat) error {
	var buckets bucketMap

	if s == nil {
		return log.Errorf("dropping nil stat")
	} else if s.Timestamp.After(b.futureBucketMinTime.Add(time.Nanosecond * (NaonsecondsPerMin - 1))) {
		// TODO: insert a "meta stat" representing a dropped future stat
		return log.Warnf("Bucketer: dropping 'future' stat that is 'after' %v: %+v", b.futureBucketMinTime.Add(time.Nanosecond*(NaonsecondsPerMin-1)), *s)
	}

	if s.Timestamp.After(b.futureBucketMinTime) || s.Timestamp.Equal(b.futureBucketMinTime) {
		buckets = b.futureBuckets
	} else if s.Timestamp.After(b.currentBucketMinTime) || s.Timestamp.Equal(b.currentBucketMinTime) {
		buckets = b.currentBuckets
	} else if s.Timestamp.After(b.previousBucketMinTime) || s.Timestamp.Equal(b.previousBucketMinTime) {
		buckets = b.previousBuckets
	} else {
		// TODO: insert a "meta stat" representing a dropped 'too old' stat
		return log.Warnf("Bucketer: dropping stat older than %v: %+v", b.previousBucketMinTime, *s)
	}

	stats := buckets[s.Name]
	stats = append(stats, s)
	buckets[s.Name] = stats
	return nil
}
400951
func (tr *RTree) Insert(min, max []float64, item interface{}) {
	if len(min) != tr.dims || len(max) != tr.dims {
		panic("invalid dimensions")
	}
	if item == nil {
		panic("nil item")
	}
	bbox := treeNode{min: min, max: max}
	tr.insert(&bbox, item, tr.data.height-1, false)
}
385478
func Insert(table string) *InsertBuilder {
	return &InsertBuilder{
		tableName: table,
		query:     fmt.Sprintln(`INSERT INTO`, table),
		lock:      new(sync.Mutex),
	}
}
1122451
func (l *PacketList) insert(e, at *PacketElement) *PacketElement {
	n := at.next
	at.next = e
	e.prev = at
	e.next = n
	n.prev = e
	e.list = l
	l.len++
	return e
}
709255
func (sk *Sketch) Insert(e []byte) bool {
	x := hash(e)
	return sk.InsertHash(x)
}
1145910
func (h *heap) insert(value []float64, length float64, srcRowNo int) {
	node := heapNode{}
	node.length = length
	node.srcRowNo = srcRowNo
	node.value = make([]float64, len(value))
	copy(node.value, value)
	h.tree = append(h.tree, node)

	target := len(h.tree)
	for target != 1 {
		if h.tree[(target/2)-1].length >= h.tree[target-1].length {
			break
		}
		h.tree[target-1], h.tree[(target/2)-1] = h.tree[(target/2)-1], h.tree[target-1]
		target /= 2
	}
}
69852
func Insert(topic *db.Topic) string {
	return db.Conn.Insert(db.TopicCollection, topic)
}
169968
func (s Int64) Insert(items ...int64) {
	for _, item := range items {
		s[item] = Empty{}
	}
}
296669
func (t *Table) Insert(row Row) error {
	if len(t.rows) > 0 && len(t.rows[0]) != len(row) {
		return InconsistentRowsError{existingRows: len(t.rows), newRow: len(row)}
	}
	t.rows = append(t.rows, row)
	t.nInserts++
	return nil
}
1370038
func (t *Tree) Insert(k []byte, v interface{}) (*Tree, interface{}, bool) {
	txn := t.Txn()
	old, ok := txn.Insert(k, v)
	return txn.Commit(), old, ok
}
1349182
func (o *orderedMap) Insert(key string, value interface{}) {
	if o.backingMap == nil {
		o.backingMap = map[string]interface{}{}
	}
	if o.orderedKeys == nil {
		o.orderedKeys = list.New()
	}

	if _, exists := o.backingMap[key]; !exists {
		o.orderedKeys.PushBack(key)
	}
	o.backingMap[key] = value
}
1030282
func (all *assetLruList) insert(alle, at *assetLruListElement) *assetLruListElement {
	n := at.next
	at.next = alle
	alle.prev = at
	alle.next = n
	n.prev = alle
	alle.list = all
	all.len++
	return alle
}
1128593
func (s *ChocolateStorage) Insert(c model.Chocolate) string {
	id := fmt.Sprintf("%d", s.idCount)
	c.ID = id
	s.chocolates[id] = &c
	s.idCount++
	return id
}
584249
func (s *nodeStack) insert(i int, n *Node) {
	(*s) = append(*s, nil)
	copy((*s)[i+1:], (*s)[i:])
	(*s)[i] = n
}
996537
func (t *Table) Insert() (stmt string, names []string) {
	return t.insert.stmt, t.insert.names
}
297630
func Insert(db DB, table string, src interface{}) error {
	return Default.Insert(db, table, src)
}
1141989
func (bucket *kbucket) Insert(no *node) bool {
	isNew := !bucket.nodes.HasKey(no.id.RawString())

	bucket.nodes.Push(no.id.RawString(), no)
	bucket.UpdateTimestamp()

	return isNew
}