public SwiftSet(nint capacity) : this(SwiftNominalCtorArgument.None) { unsafe { fixed(byte *retvalData = StructMarshal.Marshaler.PrepareNominal(this)) { SetPI.NewSet(new IntPtr(retvalData), capacity, StructMarshal.Marshaler.Metatypeof(typeof(T)), StructMarshal.Marshaler.ProtocolWitnessof(typeof(ISwiftHashable), typeof(T))); } } }
public unsafe bool Contains(T key) { fixed(byte *thisPtr = SwiftData) { var thisIntPtr = new IntPtr(thisPtr); byte *keyBuffer = stackalloc byte [StructMarshal.Marshaler.Sizeof(typeof(T))]; var keyBufferPtr = new IntPtr(keyBuffer); StructMarshal.Marshaler.ToSwift(typeof(T), key, keyBufferPtr); var val = (nint)0; val = SetPI.SetContains(thisIntPtr, keyBufferPtr, StructMarshal.Marshaler.Metatypeof(typeof(T)), StructMarshal.Marshaler.ProtocolWitnessof(typeof(ISwiftHashable), typeof(T))); StructMarshal.Marshaler.ReleaseSwiftPointer(typeof(T), keyBufferPtr); return((val & 1) != 0); } }
public unsafe SwiftOptional <T> Remove(T key) { fixed(byte *thisPtr = SwiftData) { var thisIntPtr = new IntPtr(thisPtr); byte *keyBuffer = stackalloc byte [StructMarshal.Marshaler.Sizeof(typeof(T))]; var keyBufferPtr = new IntPtr(keyBuffer); StructMarshal.Marshaler.ToSwift(typeof(T), key, keyBufferPtr); byte *retBuffer = stackalloc byte [StructMarshal.Marshaler.Sizeof(typeof(SwiftOptional <T>))]; var retBufferPtr = new IntPtr(retBuffer); SetPI.SetRemove(retBufferPtr, thisIntPtr, keyBufferPtr, StructMarshal.Marshaler.Metatypeof(typeof(T)), StructMarshal.Marshaler.ProtocolWitnessof(typeof(ISwiftHashable), typeof(T))); StructMarshal.Marshaler.ReleaseSwiftPointer(typeof(T), keyBufferPtr); return(StructMarshal.Marshaler.ToNet <SwiftOptional <T> > (retBufferPtr)); } }
public static SwiftMetatype GetSwiftMetatype() { return(SetPI.PIMetadataAccessor_SwiftSet(SwiftMetadataRequest.Complete, StructMarshal.Marshaler.Metatypeof(typeof(T)), StructMarshal.Marshaler.ProtocolWitnessof(typeof(ISwiftHashable), typeof(T)))); }