Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for MakeMapWithSize (0.12 sec)

  1. src/reflect/value.go

    // MakeMap creates a new map with the specified type.
    func MakeMap(typ Type) Value {
    	return MakeMapWithSize(typ, 0)
    }
    
    // MakeMapWithSize creates a new map with the specified type
    // and initial space for approximately n elements.
    func MakeMapWithSize(typ Type, n int) Value {
    	if typ.Kind() != Map {
    		panic("reflect.MakeMapWithSize of non-map type")
    	}
    	t := typ.common()
    	m := makemap(t, n)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 22 21:17:41 UTC 2024
    - 119.9K bytes
    - Viewed (0)
  2. src/reflect/all_test.go

    		t.Errorf("allocs per map assignment: want 0 got %f", allocs)
    	}
    
    	const size = 1000
    	tmp := 0
    	val := ValueOf(&tmp).Elem()
    	allocs = testing.AllocsPerRun(100, func() {
    		mv := MakeMapWithSize(TypeOf(map[int]int{}), size)
    		// Only adding half of the capacity to not trigger re-allocations due too many overloaded buckets.
    		for i := 0; i < size/2; i++ {
    			val.SetInt(int64(i))
    			mv.SetMapIndex(val, val)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 218.8K bytes
    - Viewed (0)
Back to top