func ExampleBucket_RangeItems() {
	bx, _ := buckets.Open(tempfile())
	defer os.Remove(bx.Path())
	defer bx.Close()

	// Create a new bucket named "years".
	years, _ := bx.New([]byte("years"))

	// Setup items to insert in `years` bucket
	items := []struct {
		Key, Value []byte
	}{
		{[]byte("1970"), []byte("70")},
		{[]byte("1975"), []byte("75")},
		{[]byte("1980"), []byte("80")},
		{[]byte("1985"), []byte("85")},
		{[]byte("1990"), []byte("90")}, // min = 1990
		{[]byte("1995"), []byte("95")}, // min < 1995 < max
		{[]byte("2000"), []byte("00")}, // max = 2000
		{[]byte("2005"), []byte("05")},
		{[]byte("2010"), []byte("10")},
	}

	// Insert 'em.
	if err := years.Insert(items); err != nil {
		fmt.Printf("could not insert items in `years` bucket: %v\n", err)
	}

	// Time range: 1990 <= key <= 2000.
	min := []byte("1990")
	max := []byte("2000")

	results, err := years.RangeItems(min, max)
	if err != nil {
		fmt.Printf("could not get items within range: %v\n", err)
	}

	for _, item := range results {
		fmt.Printf("%s -> %s\n", item.Key, item.Value)
	}
	// Output:
	// 1990 -> 90
	// 1995 -> 95
	// 2000 -> 00
}
// Show that we get items for keys within a given range.
Show that we get items for keys within a given range.
// Show that we get items for keys within a given range .
func ExampleBucket_RangeItems() {
	bx, _ := buckets.Open(tempfile())
	defer os.Remove(bx.Path())
	defer bx.Close()
	years, _ := bx.New([]byte("years"))
	items := []struct {
		Key, Value []byte
	}{
		{[]byte("1970"), []byte("70")},
		{[]byte("1975"), []byte("75")},
		{[]byte("1980"), []byte("80")},
		{[]byte("1985"), []byte("85")},
		{[]byte("1990"), []byte("90")}, 
		{[]byte("1995"), []byte("95")}, 
		{[]byte("2000"), []byte("00")}, 
		{[]byte("2005"), []byte("05")},
		{[]byte("2010"), []byte("10")},
	}
	if err := years.Insert(items); err != nil {
		fmt.Printf("could not insert items in `years` bucket: %v\n", err)
	}
	min := []byte("1990")
	max := []byte("2000")
	results, err := years.RangeItems(min, max)
	if err != nil {
		fmt.Printf("could not get items within range: %v\n", err)
	}
	for _, item := range results {
		fmt.Printf("%s -> %s\n", item.Key, item.Value)
	}
}
func ExampleBucket_RangeItems ( ) { bx , _ := buckets . Open ( tempfile ( ) ) defer os . Remove ( bx . Path ( ) ) defer bx . Close ( ) years , _ := bx . New ( [ ] byte ( " " ) ) items := [ ] struct { Key , Value [ ] byte } { { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , { [ ] byte ( " " ) , [ ] byte ( " " ) } , } if err := years . Insert ( items ) ; err != nil { fmt . Printf ( " \n " , err ) } min := [ ] byte ( " " ) max := [ ] byte ( " " ) results , err := years . RangeItems ( min , max ) if err != nil { fmt . Printf ( " \n " , err ) } for _ , item := range results { fmt . Printf ( " \n " , item . Key , item . Value ) } }
Show that we get items for keys within a given range.
Show that we get items for keys within a given range .
// Create a new bucket named "years". // Setup items to insert in `years` bucket // min = 1990 // min < 1995 < max // max = 2000 // Insert 'em. // Time range: 1990 <= key <= 2000. // Output: // 1990 -> 90 // 1995 -> 95 // 2000 -> 00