We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
(c *Cid) Cmp(o *Cid) int
1 parent 1afa3fe commit 2cd334bCopy full SHA for 2cd334b
cid.go
@@ -410,6 +410,20 @@ func (c Cid) Bytes() []byte {
410
return []byte(c.str)
411
}
412
413
+// Cmp compares two Cids for binary sorting order.
414
+func (c *Cid) Cmp(o *Cid) int {
415
+ switch {
416
+ case c == o:
417
+ return 0
418
+ case c == nil:
419
+ return -1
420
+ case o == nil:
421
+ return 1
422
+ default:
423
+ return strings.Compare(c.str, o.str)
424
+ }
425
+}
426
+
427
// ByteLen returns the length of the CID in bytes.
428
// It's equivalent to `len(c.Bytes())`, but works without an allocation,
429
// and should therefore be preferred.
0 commit comments