示例#1
0
        public bool Remove(T key)
        {
            unsafe
            {
                fixed(byte *thisPtr = SwiftData)
                {
                    var thisIntPtr = new IntPtr(thisPtr);

                    StructMarshal.Marshaler.RetainNominalData(typeof(SwiftDictionary <T, U>), thisIntPtr, SwiftData.Length);
                    byte *keyBuffer    = stackalloc byte [StructMarshal.Marshaler.Sizeof(typeof(T))];
                    var   keyBufferPtr = new IntPtr(keyBuffer);

                    StructMarshal.Marshaler.ToSwift(typeof(T), key, keyBufferPtr);
                    bool retval = DictPI.DictRemove(thisIntPtr, keyBufferPtr,
                                                    StructMarshal.Marshaler.Metatypeof(typeof(T)),
                                                    StructMarshal.Marshaler.Metatypeof(typeof(U)),
                                                    StructMarshal.Marshaler.ProtocolWitnessof(typeof(ISwiftHashable), typeof(T)));

                    StructMarshal.Marshaler.ReleaseSwiftPointer(typeof(SwiftDictionary <T, U>), thisIntPtr);
                    StructMarshal.Marshaler.ReleaseSwiftPointer(typeof(T), keyBufferPtr);

                    return(retval);
                }
            }
        }