예제 #1
0
// Returns all nodes in order
func (tree *Tree) inOrder() []*Node {
	nodes := make([]*Node, tree.size)
	if tree.size > 0 {
		current := tree.Root
		stack := linkedliststack.New()
		done := false
		count := 0
		for !done {
			if current != nil {
				stack.Push(current)
				current = current.Left
			} else {
				if !stack.Empty() {
					currentPop, _ := stack.Pop()
					current = currentPop.(*Node)
					nodes[count] = current
					count += 1
					current = current.Right
				} else {
					done = true
				}
			}
		}
	}
	return nodes
}
예제 #2
0
파일: context.go 프로젝트: yonglehou/gam
func (cell *actorCell) stashMessage(message interface{}) {
	if cell.stash == nil {
		cell.stash = linkedliststack.New()
	}

	cell.stash.Push(message)
}
예제 #3
0
func LinkedListStackExample() {
	stack := lls.New()  // empty
	stack.Push(1)       // 1
	stack.Push(2)       // 1, 2
	stack.Values()      // 2, 1 (LIFO order)
	_, _ = stack.Peek() // 2,true
	_, _ = stack.Pop()  // 2, true
	_, _ = stack.Pop()  // 1, true
	_, _ = stack.Pop()  // nil, false (nothing to pop)
	stack.Push(1)       // 1
	stack.Clear()       // empty
	stack.Empty()       // true
	stack.Size()        // 0
}
예제 #4
0
파일: context.go 프로젝트: yonglehou/gam
func NewActorCell(props Props, parent *PID) *actorCell {

	cell := actorCell{
		parent:     parent,
		props:      props,
		supervisor: props.Supervisor(),
		behavior:   linkedliststack.New(),
		children:   hashset.New(),
		watchers:   hashset.New(),
		watching:   hashset.New(),
		message:    nil,
	}
	cell.incarnateActor()
	return &cell
}