// newInversionTree initializes a tree for storing inverted matrices.
// Note that the root node is the identity matrix as it implies
// there were no errors with the original data.
177196
func newInversionTree(dataShards, parityShards int) inversionTree {
	identity, _ := identityMatrix(dataShards)
	root := inversionNode{
		matrix:   identity,
		children: make([]*inversionNode, dataShards+parityShards),
	}
	return inversionTree{
		mutex: &sync.RWMutex{},
		root:  root,
	}
}
70660
func (r *Repository) TreeObject(h plumbing.Hash) (*object.Tree, error) {
	return object.GetTree(r.Storer, h)
}
46314
func newPathTree(caseSensitive bool, capacity int) *pathTree {
	return &pathTree{
		caseSensitive: caseSensitive,
		nodes:         stringset.New(capacity / 5), // educated guess
		leafs:         stringset.New(capacity),     // exact
	}
}
208687
func (s *Scheme) New(versionName, typeName string) (Object, error) {
	obj, err := s.raw.NewObject(versionName, typeName)
	if err != nil {
		return nil, err
	}
	return obj.(Object), nil
}
653100
func NewVersion(parent *Versions) *Version {
	version := &Version{parent: parent}
	version.Init()

	return version
}
471582
func NewInvalidVersionf(cause error, context interface{}, format string, args ...interface{}) Error {
	if format == "" {
		format = fmt.Sprintf("Invalid Version: %s", context)
	}
	return makeErrorf(InvalidVersionError, cause, format, args...)
}
431913
func newNodeDB(path string, version int, self NodeID) (*nodeDB, error) {
	if path == "" {
		return newMemoryNodeDB(self)
	}
	return newPersistentNodeDB(path, version, self)
}
349620
func (tree *MutableTree) LoadVersion(targetVersion int64) (int64, error) {
	roots, err := tree.ndb.getRoots()
	if err != nil {
		return 0, err
	}
	if len(roots) == 0 {
		return 0, nil
	}
	latestVersion := int64(0)
	var latestRoot []byte
	for version, r := range roots {
		tree.versions[version] = true
		if version > latestVersion &&
			(targetVersion == 0 || version <= targetVersion) {
			latestVersion = version
			latestRoot = r
		}
	}

	if !(targetVersion == 0 || latestVersion == targetVersion) {
		return latestVersion, fmt.Errorf("wanted to load target %v but only found up to %v",
			targetVersion, latestVersion)
	}

	t := &ImmutableTree{
		ndb:     tree.ndb,
		version: latestVersion,
	}
	if len(latestRoot) != 0 {
		t.root = tree.ndb.GetNode(latestRoot)
	}

	tree.orphans = map[string]int64{}
	tree.ImmutableTree = t
	tree.lastSaved = t.clone()
	return latestVersion, nil
}
193301
func ConvertToLtree(id uuid.UUID) string {
	converted := strings.Replace(id.String(), "-", "_", -1)
	return converted
}
834251
func NewCachedTree(h hash.Hash, cachedNodeHeight uint64) *CachedTree {
	return &CachedTree{
		cachedNodeHeight: cachedNodeHeight,

		Tree: Tree{
			hash: h,

			cachedTree: true,
		},
	}
}
945535
func (s *Scheme) New(kind unversioned.GroupVersionKind) (Object, error) {
	obj, err := s.raw.NewObject(kind)
	if err != nil {
		return nil, err
	}
	return obj.(Object), nil
}
982963
func (ub UpdateBuilder) buildTree() (exprNode, error) {
	if ub.operationList == nil {
		return exprNode{}, newUnsetParameterError("buildTree", "UpdateBuilder")
	}
	ret := exprNode{
		children: []exprNode{},
	}

	modes := modeList{}

	for mode := range ub.operationList {
		modes = append(modes, mode)
	}

	sort.Sort(modes)

	for _, key := range modes {
		ret.fmtExpr += string(key) + " $c\n"

		childNode, err := buildChildNodes(ub.operationList[key])
		if err != nil {
			return exprNode{}, err
		}

		ret.children = append(ret.children, childNode)
	}

	return ret, nil
}
787711
func New(r io.Reader) (*Tree, error) {
	n, err := html.Parse(r)
	if err != nil {
		return nil, err
	}
	if n == nil {
		return nil, fmt.Errorf("Error parsing html from reader")
	}
	return &Tree{n}, nil
}
980170
func New(db *gitobj.ObjectDatabase, t *gitobj.Tree) (*Tree, error) {
	children := make(map[string]*Tree)
	lines, _, err := linesInTree(db, t)
	if err != nil {
		return nil, err
	}

	for _, entry := range t.Entries {
		if entry.Type() != gitobj.TreeObjectType {
			continue
		}

		// For every entry in the current tree, parse its sub-trees to
		// see if they might contain a .gitattributes.
		t, err := db.Tree(entry.Oid)
		if err != nil {
			return nil, err
		}

		at, err := New(db, t)
		if err != nil {
			return nil, err
		}

		if len(at.Children) > 0 || len(at.Lines) > 0 {
			// Only include entries that have either (1) a
			// .gitattributes in their tree, or (2) a .gitattributes
			// in a sub-tree.
			children[entry.Name] = at
		}
	}

	return &Tree{
		Lines:    lines,
		Children: children,
	}, nil
}
749229
func (tree *MutableTree) GetImmutable(version int64) (*ImmutableTree, error) {
	rootHash := tree.ndb.getRoot(version)
	if rootHash == nil {
		return nil, ErrVersionDoesNotExist
	} else if len(rootHash) == 0 {
		return &ImmutableTree{
			ndb:     tree.ndb,
			version: version,
		}, nil
	}
	return &ImmutableTree{
		root:    tree.ndb.GetNode(rootHash),
		ndb:     tree.ndb,
		version: version,
	}, nil
}
216002
func (repo *Repository) GetTree(idStr string) (*Tree, error) {
	id, err := NewIDFromString(idStr)
	if err != nil {
		return nil, err
	}
	return repo.getTree(id)
}
653904
func New(prof *profile.Profile, o *Options) *Graph {
	if o.CallTree {
		return newTree(prof, o)
	}
	g, _ := newGraph(prof, o)
	return g
}