本文整理汇总了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
}
示例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
}
示例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()
}
}
示例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
}
示例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()
}
示例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()
}
}
示例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)
}
示例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)
}
}
示例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()
}
示例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
}
示例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)
}
}
示例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
}
}
}
示例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
}
}
}
示例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
}
示例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
}