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


Golang List.Init方法代碼示例

本文整理匯總了Golang中container/list.List.Init方法的典型用法代碼示例。如果您正苦於以下問題:Golang List.Init方法的具體用法?Golang List.Init怎麽用?Golang List.Init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在container/list.List的用法示例。


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

示例1: xFlushOutput

func (this *TAppDecTop) xFlushOutput(pcListPic *list.List) {
	if pcListPic == nil {
		return
	}

	//fmt.Printf("list len=%d\n", pcListPic.Len());

	for e := pcListPic.Front(); e != nil; e = e.Next() {
		pcPic := e.Value.(*TLibCommon.TComPic)
		if pcPic.GetOutputMark() {
			// write to file
			if this.m_pchReconFile != "" {
				conf := pcPic.GetConformanceWindow()
				var defDisp *TLibCommon.Window
				if this.m_respectDefDispWindow != 0 {
					defDisp = pcPic.GetDefDisplayWindow()
				} else {
					defDisp = TLibCommon.NewWindow()
				}

				this.m_cTVideoIOYuvReconFile.Write(pcPic.GetPicYuvRec(),
					conf.GetWindowLeftOffset()+defDisp.GetWindowLeftOffset(),
					conf.GetWindowRightOffset()+defDisp.GetWindowRightOffset(),
					conf.GetWindowTopOffset()+defDisp.GetWindowTopOffset(),
					conf.GetWindowBottomOffset()+defDisp.GetWindowBottomOffset())
			}

			// update POC of display order
			this.m_iPOCLastDisplay = int(pcPic.GetPOC())
			//fmt.Printf("m_iPOCLastDisplay=%d\n",this.m_iPOCLastDisplay);

			// erase non-referenced picture in the reference picture list after display
			if !pcPic.GetSlice(0).IsReferenced() && pcPic.GetReconMark() == true {
				//#if !DYN_REF_FREE
				pcPic.SetReconMark(false)

				// mark it should be extended later
				pcPic.GetPicYuvRec().SetBorderExtension(false)

				//#else
				//        pcPic->destroy();
				//        pcListPic->erase( iterPic );
				//        iterPic = pcListPic->begin(); // to the beginning, non-efficient way, have to be revised!
				//        continue;
				//#endif
			}
			pcPic.SetOutputMark(false)
		}
		//#if !DYN_REF_FREE
		if pcPic != nil {
			pcPic.Destroy()
			//delete pcPic;
			pcPic = nil
		}
		//#endif
	}

	pcListPic.Init()
	this.m_iPOCLastDisplay = -TLibCommon.MAX_INT
}
開發者ID:nacore,項目名稱:GoHM,代碼行數:60,代碼來源:TAppDecTop.go

示例2: LoadTemplates

func LoadTemplates(name string, loader TemplateLoader) (*template.Template, error) {
	load_tracker := map[string]bool{name: true}
	var load_queue list.List
	load_queue.Init()
	load_queue.PushBack(name)

	t := template.New(name).Funcs(builtins)
	for e := load_queue.Front(); e != nil; e = e.Next() {
		template_name := e.Value.(string)
		new_template, err := loader.LoadTemplate(template_name)
		if err != nil {
			return nil, err
		}

		if _, err := t.Parse(new_template.Data); err != nil {
			return nil, err
		}

		if t.Lookup(template_name) == nil {
			return nil, fmt.Errorf(`template "%s"load failed.`, template_name)
		}

		for _, new_name := range new_template.Dependencies {
			if !load_tracker[new_name] {
				load_tracker[new_name] = true
				load_queue.PushBack(new_name)
			}
		}
	}

	return t, nil
}
開發者ID:Popog,項目名稱:gotemp,代碼行數:32,代碼來源:template.go

示例3: outOfOrder

func outOfOrder(l *list.List) {
	iTotal := 25
	if iTotal > l.Len() {
		iTotal = l.Len()
	}
	ll := make([]*list.List, iTotal)

	for i := 0; i < iTotal; i++ {
		ll[i] = list.New()
	}
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	for e := l.Front(); e != nil; e = e.Next() {
		fpath, ok := e.Value.(string)
		if !ok {
			panic("The path is invalid string")
		}
		if rand.Int()%2 == 0 {
			ll[r.Intn(iTotal)].PushFront(fpath)
		} else {
			ll[r.Intn(iTotal)].PushBack(fpath)
		}
	}

	r0 := rand.New(rand.NewSource(time.Now().UnixNano()))
	l.Init()
	for i := 0; i < iTotal; i++ {
		if r0.Intn(2) == 0 {
			l.PushBackList(ll[i])
		} else {
			l.PushFrontList(ll[i])
		}
		ll[i].Init()
	}
}
開發者ID:hwch,項目名稱:go-dev,代碼行數:34,代碼來源:mp3decode.go

示例4: convertPayloadToRBSP

func (this *InputNALUnit) convertPayloadToRBSP(nalUnitBuf *list.List, pcBitstream *TLibCommon.TComInputBitstream, isVclNalUnit bool) *list.List {
	zeroCount := 0
	it_write := list.New()
	oldBuf := list.New()
	for e := nalUnitBuf.Front(); e != nil; e = e.Next() {
		//assert(zeroCount < 2 || *it_read >= 0x03);
		it_read := e.Value.(byte)
		oldBuf.PushBack(it_read)
		if zeroCount == 2 && it_read == 0x03 {
			zeroCount = 0

			e = e.Next()
			if e == nil {
				break
			} else {
				it_read = e.Value.(byte)
				oldBuf.PushBack(it_read)
			}
		}

		if it_read == 0x00 {
			zeroCount++
		} else {
			zeroCount = 0
		}
		it_write.PushBack(it_read)
	}

	//assert(zeroCount == 0);
	if isVclNalUnit {
		// Remove cabac_zero_word from payload if present
		n := 0

		e := it_write.Back()
		it_read := e.Value.(byte)
		for it_read == 0x00 {
			it_write.Remove(e)
			e = e.Prev()
			it_read = e.Value.(byte)
			n++
		}

		if n > 0 {
			fmt.Printf("\nDetected %d instances of cabac_zero_word", n/2)
		}
	}

	nalUnitBuf.Init() // = .resize(it_write - nalUnitBuf.begin());
	for e := it_write.Front(); e != nil; e = e.Next() {
		it_read := e.Value.(byte)
		nalUnitBuf.PushBack(it_read)
	}

	return oldBuf
}
開發者ID:nacore,項目名稱:GoHM,代碼行數:55,代碼來源:TDecNAL.go

示例5: empty

func empty(l *list.List, args []string) {
	// print out all elements before droping
	itemNumber := 1
	for e := l.Front(); e != nil; e = e.Next() {
		fmt.Printf("Removing item[%d]:", itemNumber)
		printJSON(e.Value)
		itemNumber++
	}

	// empty list
	l.Init()
}
開發者ID:tgrijalva,項目名稱:lst,代碼行數:12,代碼來源:lst.go

示例6: serveChannels

// Serve the clients their events and destroy them when its time
// This also triggers the done chan, when c is closed
func serveChannels(c <-chan interface{}, clients *list.List, done chan<- struct{}) {
	for {
		var (
			event       interface{}
			channelOpen bool
		)
		event = nil
		channelOpen = true
		select {
		case event, channelOpen = <-c:
		case <-time.After(120 * time.Second):
		}

		if !channelOpen {
			close(done)

			// wait so no new clients come any longer
			<-time.After(1 * time.Second)
			for client := range clientsIter(clients) {
				close(client.value.channel)
			}

			// empty all references
			clients.Init()
			return
		}

		// channel is still open
		var wg sync.WaitGroup
		for client := range clientsIter(clients) {
			select {
			case <-client.value.quit:
				// client has quit
				client.removeFrom(clients)
				continue
			default:
			}

			// client has too many strikes
			if client.value.strikes >= 5 {
				client.removeFrom(clients)
				continue
			}

			// client has not quit
			wg.Add(1)
			go sendEvent(event, client.value, &wg)
		}
		// wait for the events to be sent
		wg.Wait()
	}
}
開發者ID:kerwindena,項目名稱:koma-bot,代碼行數:54,代碼來源:channelHandling.go

示例7: TestList

func TestList(t *testing.T) {
	var myInstance *MyType
	myInstance = new(MyType)
	myInstance.name = "hello"

	var myList list.List
	myList.Init()
	myList.PushFront(myInstance)

	x := myList.Front().Value.(*MyType)

	fmt.Println((*x).name)
}
開發者ID:hypertornado,項目名稱:similar_img_finder,代碼行數:13,代碼來源:main_test.go

示例8: ListSwap

func ListSwap(ls1 *list.List, ls2 *list.List) {
	tmpLs := list.New()
	for l1 := ls1.Front(); l1 != nil; l1 = l1.Next() {
		tmpLs.PushBack(l1)
	}
	ls1 = ls1.Init()
	for l2 := ls2.Front(); l2 != nil; l2 = l2.Next() {
		ls1.PushBack(l2)
	}
	ls2 = ls2.Init()
	for tl := tmpLs.Front(); tl != nil; tl = tl.Next() {
		ls2.PushBack(tl)
	}
}
開發者ID:payfriendz,項目名稱:go-freeling,代碼行數:14,代碼來源:utils.go

示例9: flush

func (st *offlineSubTask) flush(id uint64, l *list.List) {
	path := filepath.Join(st.baseDir, fmt.Sprintf("%d", st.id), fmt.Sprintf("%d", id))
	var file *os.File
	var err error
	if file, err = open(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE); err != nil {
		panic(err)
	}
	writer := bufio.NewWriter(file)
	defer file.Close()
	for e := l.Front(); e != nil; e = e.Next() {
		msg := e.Value.(RouteMsg)
		_writeMsg(writer, msg)
		st.cacheBytes -= uint64(len(msg.Body()))
	}
	writer.Flush()
	l.Init()
}
開發者ID:Joinhack,項目名稱:pmsg,代碼行數:17,代碼來源:filestore_offlinecenter.go

示例10: parse

// Parse splits code into `Section`s
func parse(source string, code []byte) *list.List {
	lines := bytes.Split(code, []byte("\n"))
	sections := new(list.List)
	sections.Init()
	language := getLanguage(source)

	var hasCode bool
	var codeText = new(bytes.Buffer)
	var docsText = new(bytes.Buffer)

	// save a new section
	save := func(docs, code []byte) {
		// deep copy the slices since slices always refer to the same storage
		// by default
		docsCopy, codeCopy := make([]byte, len(docs)), make([]byte, len(code))
		copy(docsCopy, docs)
		copy(codeCopy, code)
		sections.PushBack(&Section{docsCopy, codeCopy, nil, nil})
	}

	for _, line := range lines {
		// if the line is a comment
		if language.commentMatcher.Match(line) {
			// but there was previous code
			if hasCode {
				// we need to save the existing documentation and text
				// as a section and start a new section since code blocks
				// have to be delimited before being sent to Pygments
				save(docsText.Bytes(), codeText.Bytes())
				hasCode = false
				codeText.Reset()
				docsText.Reset()
			}
			docsText.Write(language.commentMatcher.ReplaceAll(line, nil))
			docsText.WriteString("\n")
		} else {
			hasCode = true
			codeText.Write(line)
			codeText.WriteString("\n")
		}
	}
	// save any remaining parts of the source file
	save(docsText.Bytes(), codeText.Bytes())
	return sections
}
開發者ID:nikhilm,項目名稱:gocco,代碼行數:46,代碼來源:gocco.go

示例11: PE_ParetoTestError

func (bb *ReportQueue) PE_ParetoTestError() {
	bb.less = lessSizeTestError
	sort.Sort(bb)

	var pareto list.List
	pareto.Init()
	for i, _ := range bb.queue {
		if bb.queue[i] == nil {
			continue
		}
		pareto.PushBack(bb.queue[i])
	}

	over := len(bb.queue) - 1
	for pareto.Len() > 0 && over >= 0 {
		pe := pareto.Front()
		eLast := pe
		pb := pe.Value.(*ExprReport)
		cSize := pb.Size()
		cScore := pb.testError
		pe = pe.Next()
		for pe != nil && over >= 0 {
			pb := pe.Value.(*ExprReport)
			if pb.testError < cScore {
				cScore = pb.testError
				if pb.Size() > cSize {
					bb.queue[over] = eLast.Value.(*ExprReport)
					over--
					pareto.Remove(eLast)
					cSize = pb.Size()
					eLast = pe
				}
			}
			pe = pe.Next()
		}
		if over < 0 {
			break
		}

		bb.queue[over] = eLast.Value.(*ExprReport)
		over--
		pareto.Remove(eLast)
	}
}
開發者ID:verdverm,項目名稱:go-pge,代碼行數:44,代碼來源:report.go

示例12: DeleteBefore

/* delete all the elements with time <= t */
func DeleteBefore(t Time, L *list.List) {
	if L.Len() == 0 {
		return
	}
	back := L.Back()
	if back.Value.(Elem).GetTime() <= t {
		L = L.Init()
		return
	}
Loop:
	for {
		el := L.Front()
		if el.Value.(Elem).GetTime() <= t {
			L.Remove(el)
		} else {
			break Loop
		}
	}
}
開發者ID:jeffallen,項目名稱:go-warp,代碼行數:20,代碼來源:DT.go

示例13: DeleteAfter

/* delete all the elements with time >= t */
func DeleteAfter(t Time, L *list.List) {
	if L.Len() == 0 {
		return
	}
	front := L.Front()
	if front.Value.(Elem).GetTime() >= t {
		L = L.Init()
		return
	}
Loop:
	for {
		el := L.Back()
		if el.Value.(Elem).GetTime() >= t {
			L.Remove(el)
		} else {
			break Loop
		}
	}
}
開發者ID:jeffallen,項目名稱:go-warp,代碼行數:20,代碼來源:DT.go

示例14: tileWorker

func tileWorker(T *quadratic.Map, alternativeStack chan *list.List, sink chan<- *quadratic.Map, workerCount chan int, halt chan int, tileMaps []*quadratic.Map, chooseNextEdge func(*quadratic.Map) *quadratic.Edge, maxtiles int, tileSymmetry string, showIntermediate bool) {
	localAlternatives := new(list.List)
Work:
	for {
		select {
		case <-halt:
			halt <- 1
			fmt.Fprintf(os.Stderr, "premature halt\n")
			return
		case L := <-alternativeStack:
			L.PushFrontList(localAlternatives)
			localAlternatives.Init()
			alternativeStack <- L
		default:
			if T.Faces.Len() > maxtiles && maxtiles > 0 {
				sink <- T
				break Work
			} else if noActiveFaces(T) {
				finishTime, _, _ := os.Time()
				fmt.Fprintf(os.Stderr, "new tiling complete, took %v seconds\n", finishTime-initializationTime)
				sink <- T
				break Work
			} else if showIntermediate {
				sink <- T
			}
			alternatives := addTilesByEdge(T, tileMaps, chooseNextEdge, tileSymmetry)
			if alternatives.Len() == 0 {
				break Work
			}
			T = alternatives.Remove(alternatives.Front()).(*quadratic.Map)
			localAlternatives.PushFrontList(alternatives)
			//fmt.Fprintf(os.Stderr,"currently have %v faces\n",T.Faces.Len())
		}
	}
	L := <-alternativeStack
	L.PushFrontList(localAlternatives)
	localAlternatives.Init()
	alternativeStack <- L

	workers := <-workerCount
	workerCount <- workers - 1
}
開發者ID:ebering,項目名稱:zellij,代碼行數:42,代碼來源:zellij.go

示例15: 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 contents
func Map(value string) *list.List {
	m := make(map[string]int)
	words := strings.FieldsFunc(value, func(r rune) bool { return !unicode.IsLetter(r) })
	for i := 0; i < len(words); i++ {
		word := words[i]
		v, ok := m[word]
		if ok {
			m[word] = v + 1
		} else {
			m[word] = 1
		}
	}
	l := new(list.List)
	l.Init()
	for k, val := range m {
		kv := mapreduce.KeyValue{Key: k, Value: strconv.Itoa(val)}
		l.PushBack(kv)
	}
	//  fmt.Println("DONE WITH MAPPING PHASE\n\n")
	return l
}
開發者ID:kennyhlam,項目名稱:6824,代碼行數:24,代碼來源:wc.go


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