Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 23 for cap (0.17 sec)

  1. src/arena/arena.go

    // not be used after the arena is freed. Accessing the underlying storage of the
    // slice after free may result in a fault, but this fault is also not guaranteed.
    func MakeSlice[T any](a *Arena, len, cap int) []T {
    	var sl []T
    	runtime_arena_arena_Slice(a.a, &sl, cap)
    	return sl[:len]
    }
    
    // Clone makes a shallow copy of the input value that is no longer bound to any
    // arena it may have been allocated from, returning the copy. If it was not
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Wed Oct 12 20:23:36 GMT 2022
    - 4.3K bytes
    - Viewed (0)
  2. src/bytes/buffer_test.go

    	var cap0 int
    	for i := 0; i < 5<<10; i++ {
    		b.Write(buf)
    		b.Read(buf)
    		if i == 0 {
    			cap0 = b.Cap()
    		}
    	}
    	cap1 := b.Cap()
    	// (*Buffer).grow allows for 2x capacity slop before sliding,
    	// so set our error threshold at 3x.
    	if cap1 > cap0*3 {
    		t.Errorf("buffer cap = %d; too big (grew from %d)", cap1, cap0)
    	}
    }
    
    func BenchmarkWriteByte(b *testing.B) {
    	const n = 4 << 10
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Apr 20 01:07:29 GMT 2023
    - 18.1K bytes
    - Viewed (0)
  3. src/bytes/buffer.go

    func (b *Buffer) Len() int { return len(b.buf) - b.off }
    
    // Cap returns the capacity of the buffer's underlying byte slice, that is, the
    // total space allocated for the buffer's data.
    func (b *Buffer) Cap() int { return cap(b.buf) }
    
    // Available returns how many bytes are unused in the buffer.
    func (b *Buffer) Available() int { return cap(b.buf) - len(b.buf) }
    
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Oct 13 17:10:31 GMT 2023
    - 15.7K bytes
    - Viewed (0)
  4. src/arena/arena_test.go

    	defer a.Free()
    
    	tt := arena.New[T1](a)
    	tt.n = 1
    
    	ts := arena.MakeSlice[T1](a, 99, 100)
    	if len(ts) != 99 {
    		t.Errorf("Slice() len = %d, want 99", len(ts))
    	}
    	if cap(ts) != 100 {
    		t.Errorf("Slice() cap = %d, want 100", cap(ts))
    	}
    	ts[1].n = 42
    }
    
    func TestSmokeLarge(t *testing.T) {
    	a := arena.NewArena()
    	defer a.Free()
    	for i := 0; i < 10*64; i++ {
    		_ = arena.New[T2](a)
    	}
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Wed Oct 12 20:23:36 GMT 2022
    - 742 bytes
    - Viewed (0)
  5. src/bufio/bufio_test.go

    		// Obtain a buffer to append to.
    		b := w.AvailableBuffer()
    		if w.Available() != cap(b) {
    			t.Fatalf("Available() = %v, want %v", w.Available(), cap(b))
    		}
    
    		// While not recommended, it is valid to append to a shifted buffer.
    		// This forces Write to copy the input.
    		if rn.Intn(8) == 0 && cap(b) > 0 {
    			b = b[1:1:cap(b)]
    		}
    
    		// Append a random integer of varying width.
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Feb 10 18:56:01 GMT 2023
    - 51.5K bytes
    - Viewed (0)
  6. src/builtin/builtin.go

    // capacity" section for details.
    func len(v Type) int
    
    // The cap built-in function returns the capacity of v, according to its type:
    //
    //	Array: the number of elements in v (same as len(v)).
    //	Pointer to array: the number of elements in *v (same as len(v)).
    //	Slice: the maximum length the slice can reach when resliced;
    //	if v is nil, cap(v) is zero.
    //	Channel: the channel buffer capacity, in units of elements;
    Go
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Apr 11 20:22:45 GMT 2024
    - 12.7K bytes
    - Viewed (0)
  7. doc/next/6-stdlib/1-time.md

    prepared before that call will be sent or received after the call.
    Earlier versions of Go used channels with a one-element buffer,
    making it difficult to use `Reset` and `Stop` correctly.
    A visible effect of this change is that `len` and `cap` of timer channels
    now returns 0 instead of 1, which may affect programs that
    poll the length to decide whether a receive on the timer channel
    will succeed.
    Such code should use a non-blocking receive instead.
    
    Plain Text
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Fri Apr 12 20:57:18 GMT 2024
    - 1.5K bytes
    - Viewed (0)
  8. doc/go1.17_spec.html

    </p>
    
    <pre>
    s := make([]int, 10, 100)       // slice with len(s) == 10, cap(s) == 100
    s := make([]int, 1e3)           // slice with len(s) == cap(s) == 1000
    s := make([]int, 1&lt;&lt;63)         // illegal: len(s) is not representable by a value of type int
    s := make([]int, 10, 0)         // illegal: len(s) > cap(s)
    c := make(chan int, 10)         // channel with a buffer size of 10
    HTML
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Apr 11 20:22:45 GMT 2024
    - 211.6K bytes
    - Viewed (0)
  9. api/go1.3.txt

    pkg syscall (freebsd-arm), const SYS_ACCEPT4 ideal-int
    pkg syscall (freebsd-arm), const SYS_BINDAT = 538
    pkg syscall (freebsd-arm), const SYS_BINDAT ideal-int
    pkg syscall (freebsd-arm), const SYS_CAP_GETRIGHTS = 515
    pkg syscall (freebsd-arm), const SYS_CAP_GETRIGHTS ideal-int
    pkg syscall (freebsd-arm), const SYS_CHFLAGSAT = 540
    pkg syscall (freebsd-arm), const SYS_CHFLAGSAT ideal-int
    pkg syscall (freebsd-arm), const SYS_CONNECTAT = 539
    Plain Text
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Mon Jun 02 02:45:00 GMT 2014
    - 117K bytes
    - Viewed (0)
  10. api/go1.5.txt

    pkg bufio, method (*Reader) Discard(int) (int, error)
    pkg bufio, method (ReadWriter) Discard(int) (int, error)
    pkg bytes, func LastIndexByte([]uint8, uint8) int
    pkg bytes, method (*Buffer) Cap() int
    pkg bytes, method (*Reader) Size() int64
    pkg crypto, const SHA512_224 = 14
    pkg crypto, const SHA512_224 Hash
    pkg crypto, const SHA512_256 = 15
    pkg crypto, const SHA512_256 Hash
    Plain Text
    - Registered: Tue Apr 23 11:13:09 GMT 2024
    - Last Modified: Thu Jul 30 21:14:09 GMT 2015
    - 46.6K bytes
    - Viewed (0)
Back to top