Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for GetMap (0.11 sec)

  1. src/reflect/all_test.go

    	shouldPanic("SetCap", func() { vs.SetCap(10) })
    	shouldPanic("SetLen", func() { vs.SetLen(-1) })
    	shouldPanic("SetCap", func() { vs.SetCap(-1) })
    	shouldPanic("SetCap", func() { vs.SetCap(6) }) // smaller than len
    	vs.SetLen(5)
    	if len(xs) != 5 || cap(xs) != 8 {
    		t.Errorf("after SetLen(5), len, cap = %d, %d, want 5, 8", len(xs), cap(xs))
    	}
    	vs.SetCap(6)
    	if len(xs) != 5 || cap(xs) != 6 {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 218.8K bytes
    - Viewed (0)
  2. src/reflect/value.go

    	}
    	s.Len = n
    }
    
    // SetCap sets v's capacity to n.
    // It panics if v's Kind is not [Slice] or if n is smaller than the length or
    // greater than the capacity of the slice.
    func (v Value) SetCap(n int) {
    	v.mustBeAssignable()
    	v.mustBe(Slice)
    	s := (*unsafeheader.Slice)(v.ptr)
    	if n < s.Len || n > s.Cap {
    		panic("reflect: slice capacity out of range in SetCap")
    	}
    	s.Cap = 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)
Back to top