We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public func ICRC16ArrayCompare(a: [DataItem], b: [DataItem]) : Order.Order { for(i in Iter.range(0, a.size()-1)){ switch(dataItemCompare(a[i],b[i])){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func ICRC16MapCompare(araw: ICRC16Map, braw: ICRC16Map) : Order.Order { //sort by key let a = Array.sort<(Text, DataItem)>(araw, func(a,b){ Text.compare(a.0,b.0); }); let b = Array.sort<(Text, DataItem)>(braw, func(a,b){ Text.compare(a.0,b.0); }); for(i in Iter.range(0, a.size()-1)){ switch(Text.compare(a[i].0,b[i].0)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; switch(dataItemCompare(a[i].1,b[i].1)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func ICRC16ValueMapCompare(araw: [(DataItem, DataItem)], braw: [(DataItem,DataItem)]) : Order.Order { //sort by key let a = Array.sort<(DataItem, DataItem)>(araw, func(a,b){ dataItemCompare(a.0,b.0); }); let b = Array.sort<(DataItem, DataItem)>(braw, func(a,b){ dataItemCompare(a.0,b.0); }); for(i in Iter.range(0, a.size()-1)){ switch(dataItemCompare(a[i].0,b[i].0)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; switch(dataItemCompare(a[i].1,b[i].1)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func ICRC16SetCompare(araw: [DataItem], braw: [DataItem]) : Order.Order { //sort by key let a = Array.sort<DataItem>(araw, func(a,b){ dataItemCompare(a,b); }); let b = Array.sort<DataItem>(braw, func(a,b){ dataItemCompare(a,b); }); for(i in Iter.range(0, a.size()-1)){ switch(dataItemCompare(a[i],b[i])){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func ICRC16ClassCompare(araw: [ICRC16.PropertyShared], braw: [ICRC16.PropertyShared]) : Order.Order { //sort by key let a = Array.sort<ICRC16.PropertyShared>(araw, func(a,b){ Text.compare(a.name,b.name); }); let b = Array.sort<ICRC16.PropertyShared>(braw, func(a,b){ Text.compare(a.name,b.name); }); for(i in Iter.range(0, a.size()-1)){ switch(Text.compare(a[i].name,b[i].name)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; switch(dataItemCompare(a[i].value,b[i].value)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; switch(Bool.compare(a[i].immutable,b[i].immutable)){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func ICRC16OptionCompare(a: ?DataItem, b: ?DataItem) : Order.Order { switch(a,b){ case(?a, ?b) return dataItemCompare(a,b); case(?a, null) return #greater; case(null, ?b) return #less; case(null, null) return #equal; }; }; public func floatArrayCompare(a: [Float], b: [Float]) : Order.Order { for(i in Iter.range(0, a.size()-1)){ switch(Float.compare(a[i],b[i])){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func intArrayCompare(a: [Int], b: [Int]) : Order.Order { for(i in Iter.range(0, a.size()-1)){ switch(Int.compare(a[i],b[i])){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func natArrayCompare(a: [Nat], b: [Nat]) : Order.Order { for(i in Iter.range(0, a.size()-1)){ switch(Nat.compare(a[i],b[i])){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func nat8ArrayCompare(a: [Nat8], b: [Nat8]) : Order.Order { for(i in Iter.range(0, a.size()-1)){ switch(Nat8.compare(a[i],b[i])){ case(#equal){}; case(#less) return #less; case(#greater) return #greater; }; }; if(a.size() > b.size()) return #greater; if(a.size() < b.size()) return #less; return #equal; }; public func dataItemCompare(a: DataItem, b: DataItem) : Order.Order { switch (a, b) { case (#Array(a), #Array(b)) return ICRC16ArrayCompare(a,b); case (#Array(_), _) return #less; case (_, #Array(_)) return #greater; case (#Blob(a), #Blob(b)) return Blob.compare(a,b); case (#Blob(_), _) return #less; case (_, #Blob(_)) return #greater; case (#Bool(a), #Bool(b)) return Bool.compare(a,b); case (#Bool(_), _) return #less; case (_, #Bool(_)) return #greater; case (#Bytes(a), #Bytes(b)) return Blob.compare(Blob.fromArray(a),Blob.fromArray(b)); case (#Bytes(_), _) return #less; case (_, #Bytes(_)) return #greater; case (#Class(a), #Class(b)) return ICRC16ClassCompare(a,b); case (#Class(_), _) return #less; case (_, #Class(_)) return #greater; case (#Float(a), #Float(b)) return Float.compare(a,b); case (#Float(_), _) return #less; case (_, #Float(_)) return #greater; case (#Floats(a), #Floats(b)) return floatArrayCompare(a,b); case (#Floats(_), _) return #less; case (_, #Floats(_)) return #greater; case (#Int(a), #Int(b)) return Int.compare(a,b); case (#Int(_), _) return #less; case (_, #Int(_)) return #greater; case (#Int16(a), #Int16(b)) return Int16.compare(a,b); case (#Int16(_), _) return #less; case (_, #Int16(_)) return #greater; case (#Int32(a), #Int32(b)) return Int32.compare(a,b); case (#Int32(_), _) return #less; case (_, #Int32(_)) return #greater; case (#Int64(a), #Int64(b)) return Int64.compare(a,b); case (#Int64(_), _) return #less; case (_, #Int64(_)) return #greater; case (#Int8(a), #Int8(b)) return Int8.compare(a,b); case (#Int8(_), _) return #less; case (_, #Int8(_)) return #greater; case (#Ints(a), #Ints(b)) return intArrayCompare(a,b); case (#Ints(_), _) return #less; case (_, #Ints(_)) return #greater; case (#Map(a), #Map(b)) return ICRC16MapCompare(a,b); case (#Map(_), _) return #less; case (_, #Map(_)) return #greater; case (#Nat(a), #Nat(b)) return Nat.compare(a,b); case (#Nat(_), _) return #less; case (_, #Nat(_)) return #greater; case (#Nat16(a), #Nat16(b)) return Nat16.compare(a,b); case (#Nat16(_), _) return #less; case (_, #Nat16(_)) return #greater; case (#Nat32(a), #Nat32(b)) return Nat32.compare(a,b); case (#Nat32(_), _) return #less; case (_, #Nat32(_)) return #greater; case (#Nat64(a), #Nat64(b)) return Nat64.compare(a,b); case (#Nat64(_), _) return #less; case (_, #Nat64(_)) return #greater; case (#Nat8(a), #Nat8(b)) return Nat8.compare(a,b); case (#Nat8(_), _) return #less; case (_, #Nat8(_)) return #greater; case (#Nats(a), #Nats(b)) return natArrayCompare(a,b); case (#Nats(_), _) return #less; case (_, #Nats(_)) return #greater; case (#Option(a), #Option(b)) return ICRC16OptionCompare(a,b); case (#Option(_), _) return #less; case (_, #Option(_)) return #greater; case (#Principal(a), #Principal(b)) return Principal.compare(a,b); case (#Principal(_), _) return #less; case (_, #Principal(_)) return #greater; case (#Set(a), #Set(b)) return ICRC16SetCompare(a,b); case (#Set(_), _) return #less; case (_, #Set(_)) return #greater; case (#Text(a), #Text(b)) return Text.compare(a,b); case (#Text(_), _) return #less; case (_, #Text(_)) return #greater; case (#ValueMap(a), #ValueMap(b)) return #equal; case (#ValueMap(_), _) return #less; case (_, #ValueMap(_)) return #greater; } };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: