pairbit / it.id Goto Github PK
View Code? Open in Web Editor NEWImplementation of 12-byte ObjectId
License: MIT License
Implementation of 12-byte ObjectId
License: MIT License
& to _
< to ~
> to |
IT.Id.MessagePack
Oo -> 0
iIlL -> 1
uU -> V
// - a/5/856
/// - a/5/8/56
\\ - a\5\856
\\\ - a\5\8\56
|| - auto
||| - auto
O0 -> o
Il -> 1
Add tests
ToBase32 custom abc
ToBase58 custom abc
ToBase85 custom abc
ToBase64Path*()
ToBase64Path*(char sep)
Move System.Id and System.Idf to
IT.Id and IT.Idf
MachinePid to reverse
OperationStatus TryParse
OperationStatus TryFormat
Unsafe.Add(ref Unsafe.As<Id, byte>(ref id), 15) = byte
if (c < Hex.Min || c > Hex.Max) throw Ex.InvalidByte(Idf.Hex, c);
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
https://github.com/pairbit/IT.Id/actions/runs/3524627220/jobs/5910285826
Span buffer = stackalloc byte[8];
buffer[0] = timestamp5;
buffer[1] = timestamp4;
buffer[2] = timestamp3;
buffer[3] = timestamp2;
buffer[4] = timestamp1;
buffer[5] = timestamp0; // [6], [7] = 0
var timestampMilliseconds = Unsafe.As<byte, long>(ref MemoryMarshal.GetReference(buffer));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool EqualsCore(in Guid left, in Guid right)
{
if (Vector128.IsHardwareAccelerated)
{
return Vector128.LoadUnsafe(ref Unsafe.As<Guid, byte>(ref Unsafe.AsRef(in left))) == Vector128.LoadUnsafe(ref Unsafe.As<Guid, byte>(ref Unsafe.AsRef(in right)));
}
ref int rA = ref Unsafe.AsRef(in left._a);
ref int rB = ref Unsafe.AsRef(in right._a);
// Compare each element
return rA == rB
&& Unsafe.Add(ref rA, 1) == Unsafe.Add(ref rB, 1)
&& Unsafe.Add(ref rA, 2) == Unsafe.Add(ref rB, 2)
&& Unsafe.Add(ref rA, 3) == Unsafe.Add(ref rB, 3);
}
ToHex
ToHexUpper
ToBase32(abc)
ToBase58(abc)
ToBase64
ToBase64Url
ToBase64Path2(char sep)
ToBase85(abc)
ParseHex
ParseBase64
ulong h64 = (((ulong)(*(i + 1)) << 32) | (*i))
Rename path2 to Base64Path2 (18 length)
Rename path3 to Base64Path3 (19 length)
Base32Path2 (22 length) format v/
32+32^2 = 1 056
Base32Path3 (23 length) format v//
32+32^2+32^3 = 33 824
Base64Path2 (18 length)
Win = 38^2 + 38 = 1 482
Linux = 64^2 + 64 = 4 160
Base64Path3 (19 length)
Win = 38^3 + 38^2 + 38 = 56 354
Linux = 64^3 + 64^2 + 64 = 266 304
IMinMaxValue
ISpanParsable
ToBase
ToString
ParseBase.String
Parse.String
ParseByLen.String
TryParseBase.String
TryParse.String
TryParseByLen.String
TryToBase.String
TryFormat.String
ParseBase.Bytes
Parse.Bytes
ParseByLen.Bytes
TryParseBase.Bytes
TryParse.Bytes
TryParseByLen.Bytes
new Id32(Id, Int32)
new Id32(Id, byte, byte, byte, byte)
new Id32(Id, short, short)
Int32 Value
Id32.New(Int32 value)
Id32.NewObjectId(Int32)
Id32 to Guid
Hex, Base32 and Base64
ToHex(int)
ToBase32(int)
ToBase64(int)
GetMaxValue(length, Idf)
GetMaxValueHex
GetLengthHex(int)
GetLengthBase32(int)
GetLength(int, Idf)
TryToHex(int, span)
TryToBase32
TryToBase64
Id32 ParseHex
Int32 ParseInt
Int32 ParseIntHex
int TryParseInt(chars, Idf)
int TryParseIntHex
Span span = stackalloc char[20];
TryWrite(span);
unsafe
{
return new string((char*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(span)), 0, 26);
ToString(Idf format, Bool withMarker)
Parse(Idf format)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.