本文整理匯總了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
}
示例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()
}
示例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}
}
示例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}
}
示例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}
}
示例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")
}
示例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}
}
示例8: getBuilderMap
func getBuilderMap(builder interface{}) ps.Map {
b := convert(builder, Builder{}).(Builder)
if b.builderMap == nil {
return ps.NewMap()
}
return b.builderMap
}
示例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}
}
示例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}
}
示例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()
}
示例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.
示例13: NewTestEventStorage
func NewTestEventStorage() (storage *TestEventStorage) {
storage = new(TestEventStorage)
storage.events = ps.NewMap()
return
}
示例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
示例15: NewDatabase
// NewDatabase returns a new, empty database
func NewDatabase() Database {
var db mapDb
db.clauseCount = 0
db.predicates = ps.NewMap()
return &db
}