github.com/tunabay/go-bitarray@v1.3.1/bitarray_compare_example_test.go (about)

     1  // Copyright (c) 2021 Hirotsuna Mizuno. All rights reserved.
     2  // Use of this source code is governed by the MIT license that can be found in
     3  // the LICENSE file.
     4  
     5  package bitarray_test
     6  
     7  import (
     8  	"fmt"
     9  
    10  	"github.com/tunabay/go-bitarray"
    11  )
    12  
    13  func ExampleCompare() {
    14  	x := bitarray.MustParse("11100010 1100111")
    15  	y := bitarray.MustParse("11100010 100")
    16  	fmt.Println(bitarray.Compare(x, y))
    17  	fmt.Println(bitarray.Compare(y, x))
    18  	fmt.Println(bitarray.Compare(x, x))
    19  
    20  	// Output:
    21  	// 1
    22  	// -1
    23  	// 0
    24  }
    25  
    26  func ExampleBitArray_Equal() {
    27  	ba1 := bitarray.MustParse("1100-0010 001")
    28  	ba2 := bitarray.MustParse("0011-1101 110")
    29  	fmt.Println(ba1.Equal(ba2))
    30  	fmt.Println(ba1.Equal(ba2.Not()))
    31  
    32  	// Output:
    33  	// false
    34  	// true
    35  }