// NewTreeVertex creates a new vertex with a given unique id and a given arbitrary data
326636
func NewTreeVertex(id string, data interface{}, descendants ...*TreeVertex) *TreeVertex {
	return &TreeVertex{
		Id:          id,
		Data:        data,
		Descendants: descendants,
	}
}
529342
func (t *treeGenerator) newTriple(parent, descendant *node.Node) (*triple.Triple, error) {
	return triple.New(parent, t.predicate, triple.NewNodeObject(descendant))
}
132428
func NewTreeView() *TreeView {
	return &TreeView{
		Box:           NewBox(),
		graphics:      true,
		graphicsColor: Styles.GraphicsColor,
	}
}
1135750
func (p PaddedCell) EntryVertex() Point {
	// The curve enters at the (0,0) vertex unless the axis directions are
	// reversed, in which case it enters at the (1,1) vertex.
	i := p.iLo
	j := p.jLo
	if p.orientation&invertMask != 0 {
		ijSize := sizeIJ(p.level)
		i += ijSize
		j += ijSize
	}
	return Point{faceSiTiToXYZ(p.id.Face(), uint32(2*i), uint32(2*j)).Normalize()}
}
1073602
func (t inversionTree) InsertInvertedMatrix(invalidIndices []int, matrix matrix, shards int) error {
	// If no invalid indices were given then we are done because the
	// root node is already set with the identity matrix.
	if len(invalidIndices) == 0 {
		return errAlreadySet
	}

	if !matrix.IsSquare() {
		return errNotSquare
	}

	// Lock the tree for writing and reading before accessing the tree.
	t.mutex.Lock()
	defer t.mutex.Unlock()

	// Recursively create nodes for the inverted matrix in the tree until
	// we reach the node to insert the matrix to.  We start by passing in
	// 0 as the parent index as we start at the root of the tree.
	t.root.insertInvertedMatrix(invalidIndices, matrix, shards, 0)

	return nil
}
836856
func newTreePermutation(root *TreeVertex) *treePermutations {
	return &treePermutations{
		descendantPermutations: make(map[*TreeVertex][][]*TreeVertex),
		originalRoot:           root,
		permutations:           []*TreeVertex{root},
	}
}
964658
func NewTxRecordFromMsgTx(msgTx *wire.MsgTx, received time.Time) (*TxRecord, error) {
	buf := bytes.NewBuffer(make([]byte, 0, msgTx.SerializeSize()))
	err := msgTx.Serialize(buf)
	if err != nil {
		str := "failed to serialize transaction"
		return nil, storeError(ErrInput, str, err)
	}
	rec := &TxRecord{
		MsgTx:        *msgTx,
		Received:     received,
		SerializedTx: buf.Bytes(),
		Hash:         msgTx.TxHash(),
	}

	return rec, nil
}
347008
func (g *Graph) removeVertex_locked(v *namedVertex) {
	g.graph.RemoveNode(v)
	delete(g.destinationEdgeIndex, v.ID())
	delete(g.vertices[v.vertexType][v.namespace], v.name)
	if len(g.vertices[v.vertexType][v.namespace]) == 0 {
		delete(g.vertices[v.vertexType], v.namespace)
	}
}
1322014
func (s *GlobalStore) nodeIndex(addr common.Address) (index int, found bool) {
	l := len(s.nodes)
	index = sort.Search(l, func(i int) bool {
		return bytes.Compare(s.nodes[i][:], addr[:]) >= 0
	})
	found = index < l && bytes.Equal(s.nodes[index][:], addr[:])
	return index, found
}
210120
func marshalVertexID(v Vertex) string {
	val := reflect.ValueOf(v)
	switch val.Kind() {
	case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
		return strconv.Itoa(int(val.Pointer()))
	case reflect.Interface:
		return strconv.Itoa(int(val.InterfaceData()[1]))
	}

	if v, ok := v.(Hashable); ok {
		h := v.Hashcode()
		if h, ok := h.(string); ok {
			return h
		}
	}

	// fallback to a name, which we hope is unique.
	return VertexName(v)

	// we could try harder by attempting to read the arbitrary value from the
	// interface, but we shouldn't get here from terraform right now.
}
1202763
func (s *Server) newTikvHandlerTool() *tikvHandlerTool {
	var tikvStore tikv.Storage
	store, ok := s.driver.(*TiDBDriver)
	if !ok {
		panic("Invalid KvStore with illegal driver")
	}

	if tikvStore, ok = store.store.(tikv.Storage); !ok {
		panic("Invalid KvStore with illegal store")
	}

	regionCache := tikvStore.GetRegionCache()

	return &tikvHandlerTool{
		helper.Helper{
			RegionCache: regionCache,
			Store:       tikvStore,
		},
	}
}
765126
func NewTreeNode(tree *TreeCache, path string, parent *TreeNode) *TreeNode {
	depth := 0
	if parent != nil {
		depth = parent.depth + 1
	}
	return &TreeNode{
		tree:     tree,
		state:    NodeStatePENDING,
		parent:   parent,
		path:     path,
		children: make(map[string]*TreeNode),
		depth:    depth,
	}
}
1232713
func (t TreePalette) IndexNear(c color.Color) (i int) {
	if t.Root == nil {
		return -1
	}
	t.Search(c, func(leaf *Node) { i = leaf.Index })
	return
}
214924
func (l *Loop) findVertex(p Point) (index int, ok bool) {
	const notFound = 0
	if len(l.vertices) < 10 {
		// Exhaustive search for loops below a small threshold.
		for i := 1; i <= len(l.vertices); i++ {
			if l.Vertex(i) == p {
				return i, true
			}
		}
		return notFound, false
	}

	it := l.index.Iterator()
	if !it.LocatePoint(p) {
		return notFound, false
	}

	aClipped := it.IndexCell().findByShapeID(0)
	for i := aClipped.numEdges() - 1; i >= 0; i-- {
		ai := aClipped.edges[i]
		if l.Vertex(ai) == p {
			if ai == 0 {
				return len(l.vertices), true
			}
			return ai, true
		}

		if l.Vertex(ai+1) == p {
			return ai + 1, true
		}
	}
	return notFound, false
}
566829
func NewText(f *Font, scaleMin, scaleMax float32) (t *Text) {
	t = &Text{}
	t.Font = f

	// text hover values
	// "resting state" of a text object is the min scale
	t.ScaleMin, t.ScaleMax = scaleMin, scaleMax
	t.SetScale(1)
	glfloat_size := int32(4)

	// stride of the buffered data
	xy_count := int32(2)
	stride := xy_count + int32(2)

	gl.GenVertexArrays(1, &t.vao)
	gl.GenBuffers(1, &t.vbo)
	gl.GenBuffers(1, &t.ebo)

	// vao
	gl.BindVertexArray(t.vao)

	// i think this call isnt necessary here
	// gl.ActiveTexture(gl.TEXTURE0)

	gl.BindTexture(gl.TEXTURE_2D, t.Font.textureID)

	// vbo
	// specify the buffer for which the VertexAttribPointer calls apply
	gl.BindBuffer(gl.ARRAY_BUFFER, t.vbo)

	gl.EnableVertexAttribArray(t.Font.centeredPositionAttribute)
	gl.VertexAttribPointer(
		t.Font.centeredPositionAttribute,
		2,
		gl.FLOAT,
		false,
		glfloat_size*stride,
		gl.PtrOffset(0),
	)

	gl.EnableVertexAttribArray(t.Font.uvAttribute)
	gl.VertexAttribPointer(
		t.Font.uvAttribute,
		2,
		gl.FLOAT,
		false,
		glfloat_size*stride,
		gl.PtrOffset(int(glfloat_size*xy_count)),
	)

	// ebo
	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, t.ebo)

	// i am guessing that order is important here
	gl.BindVertexArray(0)
	gl.BindBuffer(gl.ARRAY_BUFFER, 0)
	gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0)
	return t
}
1059291
func (sim *simra) NewTextTexture(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) *Texture {
	simlog.FuncIn()

	gl := sim.gl
	tex := gl.MakeTextureByText(text, fontsize, fontcolor, rect.Rectangle)
	t := &Texture{
		simra:   sim,
		texture: gl.NewTexture(tex),
	}
	runtime.SetFinalizer(t, (*Texture).release)

	simlog.FuncOut()
	return t
}
193301
func ConvertToLtree(id uuid.UUID) string {
	converted := strings.Replace(id.String(), "-", "_", -1)
	return converted
}