當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。