当前位置: 首页>>代码示例>>Golang>>正文


Golang list.PushBack函数代码示例

本文整理汇总了Golang中container/list.PushBack函数的典型用法代码示例。如果您正苦于以下问题:Golang PushBack函数的具体用法?Golang PushBack怎么用?Golang PushBack使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PushBack函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: expandClass

func expandClass(regex []int) string {
	list := New()
	list.Init()
	nextEscape := false
	escaped := false
	var toDelete *Element
	for reg_index := 0; reg_index < len(regex); reg_index++ {
		escaped = nextEscape
		nextEscape = false
		switch regex[reg_index] {
		case '\\':
			if escaped {
				escaped = false
				list.PushBack(int('\\'))
				toDelete = nil
			} else {
				nextEscape = true
				toDelete = list.PushBack(int('\\'))
			}
			break
		case '-':
			if escaped {
				escaped = false
				list.PushBack(int('-'))
				toDelete.Value = Delete
			} else {
				if reg_index > 0 && reg_index < len(regex)-1 {
					start := regex[reg_index-1]
					end := uint8(regex[reg_index+1])
					for char := uint8(start + 1); char < end; char++ {
						list.PushBack(int(char))
					}
				} else {
					//ERROR
					fmt.Println("invalid character class")
				}
			}
			break
		default:
			list.PushBack(regex[reg_index])
			break
		}
	}
	for e := list.Front(); e != nil; e = e.Next() {
		if e.Value.(int) == Delete {
			list.Remove(e)
		}
	}
	out := string(list.Remove(list.Front()).(int))
	for e := list.Front(); e != nil; e = e.Next() {
		out += string('|')
		out += string(e.Value.(int))
	}
	return out
}
开发者ID:bjh83,项目名称:stammer,代码行数:55,代码来源:preprocessor.go

示例2: MakeList

func MakeList(args ...Data) List {
	list := CreateList()
	for _, arg := range args {
		list.PushBack(arg)
	}
	return list
}
开发者ID:Bunkerbewohner,项目名称:gamelisp,代码行数:7,代码来源:data.go

示例3: readASN1CertList

// Reads a list of ASN1Cert types from |r|
func readASN1CertList(r io.Reader, totalLenBytes int, elementLenBytes int) ([]ASN1Cert, error) {
	listBytes, err := readVarBytes(r, totalLenBytes)
	if err != nil {
		return []ASN1Cert{}, err
	}
	list := list.New()
	listReader := bytes.NewReader(listBytes)
	var entry []byte
	for err == nil {
		entry, err = readVarBytes(listReader, elementLenBytes)
		if err != nil {
			if err != io.EOF {
				return []ASN1Cert{}, err
			}
		} else {
			list.PushBack(entry)
		}
	}
	ret := make([]ASN1Cert, list.Len())
	i := 0
	for e := list.Front(); e != nil; e = e.Next() {
		ret[i] = e.Value.([]byte)
		i++
	}
	return ret, nil
}
开发者ID:jfrazelle,项目名称:cfssl,代码行数:27,代码来源:serialization.go

示例4: GetConnectedUsers

// UserList related:
func GetConnectedUsers(userList *list.List) *list.List {
	list := list.New()
	for e := userList.Front(); e != nil; e = e.Next() {
		list.PushBack(e.Value.(*User).Username)
	}
	return list
}
开发者ID:nodephp,项目名称:GoGameServer,代码行数:8,代码来源:user.go

示例5: memory

//==================================================
// env GODEBUG=gctrace=1,schedtrace=1000 ./grammar
//
// even one struct{xxx} nested into another struct{xxx} the gc can
// collect the memory too.
//==================================================
func memory() {
	type stdata struct {
		data [64 * 1024]byte
	}
	type stmemory struct {
		used int
		data *stdata
	}

	list := list.New()
	i := 0
	for {
		c := new(stmemory)
		d := new(stdata)
		c.data = d
		list.PushBack(c)
		time.Sleep(10 * time.Millisecond)
		if c == nil {
			break
		}
		i++
		if i%1024 == 0 {
			i = 0
			//this will cause gc to collect memory to the minimal size
			fmt.Printf("do list init\n")
			list.Init()
		}
	}
}
开发者ID:oswystan,项目名称:studygo,代码行数:35,代码来源:main.go

示例6: Add

func (txs *txStore) Add(tx string, f *frame.Frame) error {
	if list, ok := txs.transactions[tx]; ok {
		f.Header.Del(frame.Transaction)
		list.PushBack(f)
		return nil
	}
	return txUnknown
}
开发者ID:MySportsBox,项目名称:stomp,代码行数:8,代码来源:tx_store.go

示例7: main

func main() {
	for i := 0; i < 100000; i++ {
		list := list.New()
		for j := 0; j < 10000; j++ {
			myStruct := new(MyStruct)
			list.PushBack(myStruct)
		}
	}
}
开发者ID:cesarkuroiwa,项目名称:golang,代码行数:9,代码来源:gc.go

示例8: Map

func (ls List) Map(f func(a Data, i int) Data) List {
	list := CreateList()
	i := 0

	for e := ls.Front(); e != nil; e = e.Next() {
		switch t := e.Value.(type) {
		case Data:
			list.PushBack(f(t, i))
		}
		i++
	}

	return list
}
开发者ID:Bunkerbewohner,项目名称:gamelisp,代码行数:14,代码来源:data.go

示例9: MatchAll

func MatchAll(m *Matcher, text string) []Match {
	list := list.New()
	ch := m.Match(text)
	for n := range ch {
		list.PushBack(n)
	}
	all := make([]Match, list.Len())
	idx := 0
	for e := list.Front(); e != nil; e = e.Next() {
		all[idx] = e.Value.(Match)
		idx++
	}
	return all
}
开发者ID:k-takata,项目名称:nvcheck,代码行数:14,代码来源:match_all.go

示例10: Map

func Map(value string) *list.List {
	list := list.New()

	f := func(c rune) bool {
		return !unicode.IsLetter(c) && !unicode.IsNumber(c)
	}

	array_str := strings.FieldsFunc(value, f)
	for i := 0; i < len(array_str); i++ {
		fmt.Println("Element", i, "of array is", array_str[i])
		list.PushBack(array_str[i])
	}
	return list
}
开发者ID:simplehpt,项目名称:lecture,代码行数:14,代码来源:list_example.go

示例11: compressSubGraph

func compressSubGraph(letterCount int, subGraph map[string]*WordNode, done chan bool) {
	for _, node := range subGraph {
		list := list.New()
		for letter := 0; letter < letterCount; letter++ {
			for _, edge := range node.Edges[letter] {
				if edge != nil {
					list.PushBack(edge)
				}
			}
		}
		node.Neighbours = listToNodeSlice(list)
		node.Edges = nil
	}
	done <- true
}
开发者ID:nerophon,项目名称:dictdash,代码行数:15,代码来源:wordGraph.go

示例12: Filter

func (ls List) Filter(f func(a Data, i int) bool) List {
	list := CreateList()
	i := 0

	for e := ls.Front(); e != nil; e = e.Next() {
		switch t := e.Value.(type) {
		case Data:
			if f(t, i) {
				list.PushBack(t)
			}
		}
		i++
	}

	return list
}
开发者ID:Bunkerbewohner,项目名称:gamelisp,代码行数:16,代码来源:data.go

示例13: init

func (d *Discover) init() {
	//构造一个映射端口号队列列表
	list := list.New()
	startPort := 1990
	for i := 0; i < 10; i++ {
		list.PushBack(startPort)
		startPort++
	}
	d.MappingInfo = MappingInfo{OutsideMappingPort: make(map[string]int, 2), InsideMappingPort: make(map[string]int, 2)}
	d.GroupIp = "239.255.255.250:1900"
	d.DiscoverInfo = DiscoverInfo{MappingPorts: list,
		Protocols: []string{"TCP", "UDP"},
		DefaultSearchType: []string{"urn:schemas-upnp-org:service:WANIPConnection:1",
			"urn:schemas-upnp-org:service:WANPPPConnection:1",
			"urn:schemas-upnp-org:device:InternetGatewayDevice:1"}}

}
开发者ID:cokeboL,项目名称:mandela,代码行数:17,代码来源:discover.go

示例14: Map

// our simplified version of MapReduce does not supply a
// key to the Map function, as in the paper; only a value,
// which is a part of the input file content. the return
// value should be a list of key/value pairs, each represented
// by a mapreduce.KeyValue.
func Map(value string) *list.List {
	list := list.New()

	f := func(c rune) bool {
		return !unicode.IsLetter(c) && !unicode.IsNumber(c)
	}

	array_str := strings.FieldsFunc(value, f)
	for i := 0; i < len(array_str); i++ {
		var kv mapreduce.KeyValue
		kv.Key = array_str[i]
		kv.Value = "1"
		list.PushBack(kv)
	}

	return list
}
开发者ID:simplehpt,项目名称:lecture,代码行数:22,代码来源:wc.go

示例15: ParseTree

func ParseTree(tree ast.ASTNode) (*list.List, error) {
	list := list.New()

	switch node := tree.(type) {
	case *ast.BlockStmt:
		previous := current
		current = newScope()
		scopes = append(scopes, current)
		for _, stmt := range node.List() {
			l, err := ParseTree(stmt)
			if err != nil {
				return nil, err
			}
			list.PushBackList(l)
		}
		current = previous
		return list, nil
	case *ast.GenDecl:
		// declarations never push back lists
		_, err := ParseTree(node.Decl)
		if err != nil {
			return nil, err
		}

		value, err := ParseTree(node.Value)
		if err != nil {
			return nil, err
		}
		list.PushBackList(value)
	case *ast.DeclObj:
		return nil, current.declVar(node.Id)
	case *ast.AsmExpr:
		asm := strings.Split(node.Asm, "\n")
		for _, asm := range asm {
			cmt := strings.Split(asm, ";")
			if len(cmt) > 0 && len(cmt[0]) > 0 && cmt[0] != ";" {
				list.PushBack(strings.TrimSpace(cmt[0]))
			}
		}
		return list, nil
	}
	return list, nil
}
开发者ID:obscuren,项目名称:cll,代码行数:43,代码来源:tree_parser.go


注:本文中的container/list.PushBack函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。