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


Golang vector.IntVector類代碼示例

本文整理匯總了Golang中container/vector.IntVector的典型用法代碼示例。如果您正苦於以下問題:Golang IntVector類的具體用法?Golang IntVector怎麽用?Golang IntVector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: GetPartageurs

// renvoie la liste des trolls avec qui le troll passé a un partage actif
func (store *MysqlStore) GetPartageurs(db *mysql.Client, trollId int) ([]int, os.Error) {
	st := strconv.Itoa(trollId)
	sql := "select troll_a, troll_b from partage where (troll_a=" + st + " or troll_b=" + st + ") and statut_a='on' and statut_b='on'"
	err := db.Query(sql)
	if err != nil {
		return nil, err
	}
	result, err := db.UseResult()
	if err != nil {
		return nil, err
	}
	defer result.Free()

	amis := new(vector.IntVector)
	for {
		row := result.FetchRow()
		if row == nil {
			break
		}
		r0 := fieldAsInt(row[0])
		r1 := fieldAsInt(row[1])
		if r0 == trollId {
			amis.Push(r1)
		} else {
			amis.Push(r0)
		}
	}

	return *amis, nil

}
開發者ID:Chouia,項目名稱:Chrall,代碼行數:32,代碼來源:partagestore.go

示例2: main

func main() {

	min := 113
	max := int(^uint32(0) >> 1)

	for currentSum := min; currentSum <= max; currentSum++ {
		var a Sum
		var initVector vector.IntVector

		for i := 0; i < currentSum; i += 1 {
			initVector.Push(1)
		}

		a.Init(initVector)

		count := recursiveMerging(a, currentSum, 0)

		fmt.Println(currentSum, count)

		if count%1000000 == 0 {
			panic("")
		}
	}

}
開發者ID:hydroo,項目名稱:coding-and-math-exercises,代碼行數:25,代碼來源:78.go

示例3: PrintSorted

func (d *debugHistogram) PrintSorted() {
	if !printDebugOutput {
		return
	}
	if len(d.mapping) == 0 {
		return
	}
	var scores vector.IntVector
	inverseMapping := make(map[int]string)
	sum := 0
	for key, value := range d.mapping {
		inverseMapping[value] = key
		scores.Push(value)
		sum += value
	}
	scoresArray := sort.IntArray(scores)
	scoresArray.Sort()

	fmt.Fprintf(os.Stderr, "Debug histogram - sorted:\n")
	length := len(scoresArray)
	for i := 0; i < length; i++ {
		current := scoresArray[length-i-1]
		fmt.Fprintf(os.Stderr, "%s: %d (%2.1f%%)\n", inverseMapping[current], current, float(current)/float(sum)*100)
	}
}
開發者ID:Sh4pe,項目名稱:komoku,代碼行數:25,代碼來源:debug.go

示例4: Init

func (this *Sum) Init(newElements vector.IntVector) {
	this.elements = newElements.Copy()

	this.accumulated = 0
	for _, v := range this.elements {
		this.accumulated += v
	}
}
開發者ID:hydroo,項目名稱:coding-and-math-exercises,代碼行數:8,代碼來源:76.go

示例5: removeZeros

func removeZeros(c []int) []int {
	var ret vector.IntVector
	for _, v := range c {
		if v != 0 {
			ret.Push(v)
		}
	}
	return ret
}
開發者ID:hydroo,項目名稱:coding-and-math-exercises,代碼行數:9,代碼來源:106.go

示例6: dead

func (t *GoTracker) dead() []int {
	dead := new(vector.IntVector)
	cp := t.Copy().(*GoTracker)
	color := BLACK
	move := 0
	for {
		vertex := cp.weights.Rand(color)
		cp.Play(color, vertex)
		move++
		if move > 3*t.sqsize || cp.Winner() != EMPTY {
			break
		}
		color = Reverse(color)
	}
	for i := 0; i < t.sqsize; i++ {
		if t.board[i] != EMPTY && cp.board[i] != t.board[i] {
			dead.Push(i)
		}
	}
	stones := make([]int, dead.Len())
	for i := 0; i < dead.Len(); i++ {
		stones[i] = dead.At(i)
	}
	return stones
}
開發者ID:etherealmachine,項目名稱:hivemind,代碼行數:25,代碼來源:gotracker.go

示例7: BenchmarkIntVector

func BenchmarkIntVector(b *testing.B) {
	for i := 0; i < b.N; i++ {
		var vec vector.IntVector
		for j := 0; j < vectorLength; j++ {
			vec.Push(j)
		}
		for j := 0; j < vectorLength; j++ {
			val := vec.At(j)
			val++
		}
	}
}
開發者ID:Sh4pe,項目名稱:komoku,代碼行數:12,代碼來源:design_decision_benchmark.go

示例8: generatePrimes

func generatePrimes(min int, max int) vector.IntVector {

	var ret vector.IntVector

	for n := min; n <= max; n++ {
		if isPrime(n) {
			ret.Push(n)
		}
	}

	return ret
}
開發者ID:hydroo,項目名稱:coding-and-math-exercises,代碼行數:12,代碼來源:69.go

示例9: Rollup

func (self *YesOrNo) Rollup(time int64, key string, samples *vector.IntVector) {
	data := &YesOrNoItem{}
	samples.Do(func(elem interface{}) {
		value := elem.(int)
		if value > 0 {
			data.ok++
		} else {
			data.fail++
		}
	})
	self.save(time, key, data)
}
開發者ID:COTOHA,項目名稱:gorrdpd,代碼行數:12,代碼來源:writers.go

示例10: SearchPrefix

func (connection *Connection) SearchPrefix(query string) (*vector.IntVector, os.Error) {
	var count _C_int
	resp := C.tcidbsearch(connection.Dystopia, C.CString(query), C.x_prefix(), &count)
	fmt.Printf("searched for %v, num results = %d, resp = %v\n", query, count, resp)

	var result vector.IntVector
	for i := 0; i < int(count); i++ {
		result.Push(int(C.x_get_result_item(resp, _C_int(i))))
	}

	//        return &result, nil;
	return &result, nil
}
開發者ID:patrickxb,項目名稱:godystopia,代碼行數:13,代碼來源:dystopia.go

示例11: AreTwoIntVectorEquals

func AreTwoIntVectorEquals(vector1, vector2 *vector.IntVector) bool {
	if vector1.Len() != vector2.Len() {
		return false
	}

	for i := 0; i < vector1.Len(); i++ {
		if vector1.At(i) != vector2.At(i) {
			return false
		}
	}

	return true
}
開發者ID:andrewsmedina,項目名稱:euler,代碼行數:13,代碼來源:12_test.go

示例12: find

// find all occurrences of s in source; report at most n occurences
func find(src, s string, n int) []int {
	var res vector.IntVector
	if s != "" && n != 0 {
		// find at most n occurrences of s in src
		for i := -1; n < 0 || len(res) < n; {
			j := strings.Index(src[i+1:], s)
			if j < 0 {
				break
			}
			i += j + 1
			res.Push(i)
		}
	}
	return res
}
開發者ID:IntegerCompany,項目名稱:linaro-android-gcc,代碼行數:16,代碼來源:suffixarray_test.go

示例13: readLexeme

func readLexeme(state *LexerState,
	rune int,
	size int,
	err os.Error,
	predicate func(rune int) bool,
	reader *bufio.Reader) (string, os.Error) {
	var runes vector.IntVector
	for predicate(rune) && size > 0 && err == nil {
		runes.Push(rune)
		rune, size, err = readRune(state, reader)
	}
	if err != os.EOF {
		unreadRune(state, reader, rune)
	}
	return lexeme(runes), err
}
開發者ID:klutometis,項目名稱:dragonbook,代碼行數:16,代碼來源:lexer.go

示例14: checkValues

func checkValues(trie *Trie, s string, v *vector.IntVector, t *testing.T) {
	value, ok := trie.GetValue(s)
	values := value.(*vector.IntVector)
	if !ok {
		t.Fatalf("No value returned for string '%s'", s)
	}

	if values.Len() != v.Len() {
		t.Fatalf("Length mismatch: Values for '%s' should be %v, but got %v", s, *v, *values)
	}
	for i := 0; i < values.Len(); i++ {
		if values.At(i) != v.At(i) {
			t.Fatalf("Content mismatch: Values for '%s' should be %v, but got %v", s, *v, *values)
		}
	}
}
開發者ID:AlanQuatermain,項目名稱:go-trie,代碼行數:16,代碼來源:trie_test.go

示例15: generatePrimes

func generatePrimes(min int, max int) []int {

	var primes vector.IntVector

	for n := min; n <= max; n++ {
		if isPrime(n) {
			primes.Push(n)
		}
	}

	ret := make([]int, len(primes))
	for k, v := range primes {
		ret[k] = v
	}

	return ret
}
開發者ID:hydroo,項目名稱:coding-and-math-exercises,代碼行數:17,代碼來源:88-2.go


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