當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ps.NewMap函數代碼示例

本文整理匯總了Golang中github.com/mndrix/ps.NewMap函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewMap函數的具體用法?Golang NewMap怎麽用?Golang NewMap使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了NewMap函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: NewTree

// NewTree returns a new history tree.
func NewTree() (t *Tree) {
	t = new(Tree)
	t.size = 0
	t.frozen = ps.NewMap()
	t.events = ps.NewMap()
	return
}
開發者ID:pylls,項目名稱:balloon,代碼行數:8,代碼來源:historytree.go

示例2: NewBlankMachine

// NewBlankMachine creates a new Golog machine without loading the
// standard library (prelude)
func NewBlankMachine() Machine {
	var m machine
	m.db = NewDatabase()
	m.env = NewBindings()
	m.disjs = ps.NewList()
	m.conjs = ps.NewList()

	for i := 0; i < smallThreshold; i++ {
		m.smallForeign[i] = ps.NewMap()
	}
	m.largeForeign = ps.NewMap()
	return (&m).DemandCutBarrier()
}
開發者ID:vzaramel,項目名稱:golog,代碼行數:15,代碼來源:machine.go

示例3: fromIntermediate

func (c EdgeMetadatas) fromIntermediate(in map[string]EdgeMetadata) EdgeMetadatas {
	out := ps.NewMap()
	for k, v := range in {
		out = out.Set(k, v)
	}
	return EdgeMetadatas{out}
}
開發者ID:pauloheck,項目名稱:scope,代碼行數:7,代碼來源:edge_metadatas.go

示例4: fromIntermediate

func (m LatestMap) fromIntermediate(in map[string]LatestEntry) LatestMap {
	out := ps.NewMap()
	for k, v := range in {
		out = out.Set(k, v)
	}
	return LatestMap{out}
}
開發者ID:rnd-ua,項目名稱:scope,代碼行數:7,代碼來源:latest_map.go

示例5: fromIntermediate

func (c Counters) fromIntermediate(in map[string]int) Counters {
	out := ps.NewMap()
	for k, v := range in {
		out = out.Set(k, v)
	}
	return Counters{out}
}
開發者ID:dilgerma,項目名稱:scope,代碼行數:7,代碼來源:counters.go

示例6: Variables

// Variables returns a ps.Map whose keys are human-readable variable names
// and those values are *Variable used inside term t.
func Variables(t Term) ps.Map {
	names := ps.NewMap()
	switch t.Type() {
	case AtomType,
		FloatType,
		IntegerType,
		ErrorType:
		return names
	case CompoundType:
		x := t.(*Compound)
		if x.Arity() == 0 {
			return names
		} // no variables in an atom
		for _, arg := range x.Arguments() {
			innerNames := Variables(arg)
			innerNames.ForEach(func(key string, val interface{}) {
				names = names.Set(key, val)
			})
		}
		return names
	case VariableType:
		x := t.(*Variable)
		return names.Set(x.Name, x)
	}
	panic("Unexpected term implementation")
}
開發者ID:vzaramel,項目名稱:golog,代碼行數:28,代碼來源:term.go

示例7: fromIntermediate

func (s Sets) fromIntermediate(in map[string]StringSet) Sets {
	out := ps.NewMap()
	for k, v := range in {
		out = out.Set(k, v)
	}
	return Sets{out}
}
開發者ID:pauloheck,項目名稱:scope,代碼行數:7,代碼來源:sets.go

示例8: getBuilderMap

func getBuilderMap(builder interface{}) ps.Map {
	b := convert(builder, Builder{}).(Builder)

	if b.builderMap == nil {
		return ps.NewMap()
	}

	return b.builderMap
}
開發者ID:nancyandrews,項目名稱:MobileMainStreet,代碼行數:9,代碼來源:builder.go

示例9: Add

// Add adds the specs to the PluginSpecs. Add is the only valid way to grow a
// PluginSpecs. Add returns the PluginSpecs to enable chaining.
func (n PluginSpecs) Add(specs ...PluginSpec) PluginSpecs {
	result := n.psMap
	if result == nil {
		result = ps.NewMap()
	}
	for _, spec := range specs {
		result = result.Set(spec.ID, spec)
	}
	return PluginSpecs{result}
}
開發者ID:dilgerma,項目名稱:scope,代碼行數:12,代碼來源:plugin_spec.go

示例10: Add

// Add adds the nodes to the NodeSet. Add is the only valid way to grow a
// NodeSet. Add returns the NodeSet to enable chaining.
func (n NodeSet) Add(nodes ...Node) NodeSet {
	result := n.psMap
	if result == nil {
		result = ps.NewMap()
	}
	for _, node := range nodes {
		result = result.Set(node.ID, node)
	}
	return NodeSet{result}
}
開發者ID:dilgerma,項目名稱:scope,代碼行數:12,代碼來源:node_set.go

示例11: String

func (n PluginSpecs) String() string {
	keys := []string{}
	if n.psMap == nil {
		n = EmptyPluginSpecs
	}
	psMap := n.psMap
	if psMap == nil {
		psMap = ps.NewMap()
	}
	for _, k := range psMap.Keys() {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	buf := bytes.NewBufferString("{")
	for _, key := range keys {
		val, _ := psMap.Lookup(key)
		fmt.Fprintf(buf, "%s: %s, ", key, spew.Sdump(val))
	}
	fmt.Fprintf(buf, "}")
	return buf.String()
}
開發者ID:dilgerma,項目名稱:scope,代碼行數:22,代碼來源:plugin_spec.go

示例12: MakeSets

	"encoding/json"
	"fmt"
	"reflect"
	"sort"

	"github.com/mndrix/ps"
)

// Sets is a string->set-of-strings map.
// It is immutable.
type Sets struct {
	psMap ps.Map
}

// EmptySets is an empty Sets.  Starts with this.
var EmptySets = Sets{ps.NewMap()}

// MakeSets returns EmptySets
func MakeSets() Sets {
	return EmptySets
}

// Keys returns the keys for this set
func (s Sets) Keys() []string {
	if s.psMap == nil {
		return nil
	}
	return s.psMap.Keys()
}

// Add the given value to the Sets.
開發者ID:pauloheck,項目名稱:scope,代碼行數:31,代碼來源:sets.go

示例13: NewTestEventStorage

func NewTestEventStorage() (storage *TestEventStorage) {
	storage = new(TestEventStorage)
	storage.events = ps.NewMap()
	return
}
開發者ID:pylls,項目名稱:balloon,代碼行數:5,代碼來源:balloon_test.go

示例14: MakeCounters

	"encoding/gob"
	"fmt"
	"reflect"
	"sort"

	"github.com/mndrix/ps"
	"github.com/ugorji/go/codec"
)

// Counters is a string->int map.
type Counters struct {
	psMap ps.Map
}

// EmptyCounters is the set of empty counters.
var EmptyCounters = Counters{ps.NewMap()}

// MakeCounters returns EmptyCounters
func MakeCounters() Counters {
	return EmptyCounters
}

// Copy is a noop
func (c Counters) Copy() Counters {
	return c
}

// Add value to the counter 'key'
func (c Counters) Add(key string, value int) Counters {
	if c.psMap == nil {
		c = EmptyCounters
開發者ID:dilgerma,項目名稱:scope,代碼行數:31,代碼來源:counters.go

示例15: NewDatabase

// NewDatabase returns a new, empty database
func NewDatabase() Database {
	var db mapDb
	db.clauseCount = 0
	db.predicates = ps.NewMap()
	return &db
}
開發者ID:vzaramel,項目名稱:golog,代碼行數:7,代碼來源:database.go


注:本文中的github.com/mndrix/ps.NewMap函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。