// The Closer interface
196056
func (f *HttpFile) Close() error {
	DebugLog(f.Debug).Println("Close")
	f.client = nil
	f.pos = -1
	f.len = -1
	return nil
}
481070
func (schemaSwap *Swap) closeRetryChannel() {
	schemaSwap.retryMutex.Lock()
	defer schemaSwap.retryMutex.Unlock()

	if len(schemaSwap.rootUINode.Actions) != 0 {
		schemaSwap.rootUINode.Actions = []*workflow.Action{}
		close(schemaSwap.retryChannel)
	}
}
642847
func (c *Closer) Add(f CloseFunc) {
	c.m.Lock()
	defer c.m.Unlock()
	c.fs = append([]CloseFunc{f}, c.fs...)
}
998314
func (c *Client) Close() error {
	c.closedLock.Lock()
	defer c.closedLock.Unlock()

	if c.closed {
		return nil
	}
	c.closed = true
	c.client.GoAway() // Notify the other side of the close
	return c.client.Close()
}
160836
func (d *Death) closeObjects(closer closer, done chan<- closer) {
	err := closer.C.Close()
	if err != nil {
		d.log.Error(err)
		closer.Err = err
	}
	done <- closer
}
953431
func ToReadCloser(r io.Reader) io.ReadCloser {
	if rc, ok := r.(io.ReadCloser); ok {
		return rc
	}

	return struct {
		io.Reader
		io.Closer
	}{
		r,
		ioutil.NopCloser(nil),
	}
}
855278
func (s *TrendsService) Closest(params *ClosestParams) ([]Location, *http.Response, error) {
	locations := new([]Location)
	apiError := new(APIError)
	resp, err := s.sling.New().Get("closest.json").QueryStruct(params).Receive(locations, apiError)
	return *locations, resp, relevantError(err, *apiError)
}
1289605
func closestIndex(s []rune, r rune, pos int) int {

	desc := naiveSearchDescending(s, r, pos)
	asc := naiveSearchAscending(s, r, pos)

	da := math.Abs(float64(desc - pos))
	aa := math.Abs(float64(asc - pos))

	if da < aa {
		return desc
	}
	return asc
}
261765
func (cdb *CDB) Close() error {
	if closer, ok := cdb.reader.(io.Closer); ok {
		return closer.Close()
	} else {
		return nil
	}
}
941073
func (tab *Table) closest(target enode.ID, nresults int, checklive bool) *nodesByDistance {
	// This is a very wasteful way to find the closest nodes but
	// obviously correct. I believe that tree-based buckets would make
	// this easier to implement efficiently.
	close := &nodesByDistance{target: target}
	for _, b := range &tab.buckets {
		for _, n := range b.entries {
			if checklive && n.livenessChecks == 0 {
				continue
			}
			close.push(n, nresults)
		}
	}
	return close
}
1100298
func (r *QueryResponse) Close() {
	r.closeLock.Lock()
	defer r.closeLock.Unlock()
	if r.closed {
		return
	}
	r.closed = true
	if r.ackCh != nil {
		close(r.ackCh)
	}
	if r.respCh != nil {
		close(r.respCh)
	}
}
678709
func (cli *Client) Close() error {
	if t, ok := cli.client.Transport.(*http.Transport); ok {
		t.CloseIdleConnections()
	}
	return nil
}
205312
func (u readCloser) Close() error {
	if u.file != nil {
		return u.file.Close()
	}
	return nil
}
709238
func closeReopenFunc(ctx smat.Context) (next smat.State, err error) {
	c := ctx.(*smatContext)

	waitUntilClean := func() error {
		for c.coll != nil &&
			c.coll.(*collection) != nil { // Wait until dirty ops are drained.
			var stats *CollectionStats
			stats, err = c.coll.Stats()
			if err != nil {
				return err
			}

			if stats.CurDirtyOps <= 0 &&
				stats.CurDirtyBytes <= 0 &&
				stats.CurDirtySegments <= 0 {
				break
			}

			smatLog(prefix, "notifying merger, CurDirtyOps: %d\n", stats.CurDirtyOps)

			c.coll.(*collection).NotifyMerger("mergeAll", true)

			time.Sleep(200 * time.Millisecond)
		}

		return nil
	}

	err = waitUntilClean()
	if err != nil {
		return nil, err
	}

	err = closeParts(c)
	if err != nil {
		return nil, err
	}

	err = waitUntilClean()
	if err != nil {
		return nil, err
	}

	co := CollectionOptions{
		MergeOperator: &MergeOperatorStringAppend{Sep: ":"},
	}

	compactionSync := smatCompactionSync

	store, err := OpenStore(c.tmpDir, StoreOptions{
		CollectionOptions: co,
		CompactionSync:    compactionSync,
	})
	if err != nil {
		return nil, err
	}

	storeSnapshotInit, err := store.Snapshot()
	smatLog(prefix, "closeReopenFunc, storeSnapshotInit, ss: %p\n", storeSnapshotInit)
	if err != nil {
		return nil, err
	}

	smatLog(prefix, "storeSnapshotInit: %+v\n", storeSnapshotInit)

	co.LowerLevelInit = storeSnapshotInit
	co.LowerLevelUpdate = func(higher Snapshot) (Snapshot, error) {
		smatLog(prefix, "LowerLevelUpdate... higher: %+v\n", higher)
		smatLog(prefix, "LowerLevelUpdate... higher.a: %+v\n", higher.(*segmentStack).a)

		var ss Snapshot
		ss, err = store.Persist(higher, StorePersistOptions{
			CompactionConcern: smatCompactionConcern,
		})

		if err != nil {
			smatLog(prefix, "LowerLevelUpdate, err: %v\n", err)
		} else {
			smatLog(prefix, "LowerLevelUpdate, after persist, footer: %+v\n", ss.(*Footer))
		}

		return ss, err
	}
	co.OnEvent = func(ev Event) {
		if ev.Kind == EventKindClose {
			store.Close()
		}
	}

	coll, err := NewCollection(co)
	if err != nil {
		return nil, err
	}

	err = coll.Start()
	if err != nil {
		return nil, err
	}

	smatLog(prefix, "closeReopen coll: %+v\n", coll)
	ss, _ := coll.Snapshot()
	smatLog(prefix, "closeReopenFunc, coll.Snapshot, ss: %p\n", ss)

	v, err := ss.Get([]byte("2"), ReadOptions{})
	smatLog(prefix, "coll.Get(2), v: %s, err: %v\n", v, err)
	itr, _ := ss.StartIterator(nil, nil, IteratorOptions{})
	i := 0
	for {
		ik, iv, err := itr.Current()
		smatLog(prefix, "coll.Iterator().current, i: %d, k: %s, v: %s, err: %v\n", i, ik, iv, err)
		if err == ErrIteratorDone {
			break
		}
		err = itr.Next()
		if err == ErrIteratorDone {
			break
		}
		i++
	}
	itr.Close()
	ss.Close()

	c.coll = coll
	c.mo = co.MergeOperator

	return running, nil
}
755513
func (dm *DocumentMapping) closestDocMapping(path string) *DocumentMapping {
	pathElements := decodePath(path)
	current := dm
OUTER:
	for _, pathElement := range pathElements {
		for name, subDocMapping := range current.Properties {
			if name == pathElement {
				current = subDocMapping
				continue OUTER
			}
		}
		break
	}
	return current
}
410739
func (iter *iteratorSingle) Close() error {
	if iter.closer != nil {
		iter.closer.Close()
		iter.closer = nil
	}

	return nil
}
1000985
func closestMonday(date time.Time) time.Time {
	wd := date.Weekday()
	if wd == 0 {
		date = date.AddDate(0, 0, 1)
	}

	if wd == 6 {
		date = date.AddDate(0, 0, 2)
	}

	return date
}