コード例 #1
0
        /// <summary>
        /// Rehashes the keys in the map.
        /// This function must be called to create a valid map.
        /// </summary>
        public void Rehash()
        {
            IntPtr tempKeyProp = keyProp;

            HashDelegates.GetKeyHash callback = delegate(IntPtr src)
            {
                return(Native_UProperty.GetValueTypeHash(tempKeyProp, src));
            };
            map->Rehash(ref mapLayout, callback);
        }
コード例 #2
0
        /// <summary>
        /// Finds key index from hash, rather than linearly searching
        /// </summary>
        public int FindPairIndexFromHash(IntPtr keyToFind)
        {
            IntPtr localKeyPropForCapture = keyProp;

            HashDelegates.GetKeyHash keyHash = delegate(IntPtr elementKey)
            {
                return(Native_UProperty.GetValueTypeHash(localKeyPropForCapture, elementKey));
            };
            HashDelegates.Equality keyEquality = delegate(IntPtr a, IntPtr b)
            {
                return(Native_UProperty.Identical(localKeyPropForCapture, a, b, 0));
            };
            return(map->FindPairIndex(keyToFind, ref mapLayout, keyHash, keyEquality));
        }
コード例 #3
0
        /// <summary>
        /// Finds element index from hash, rather than linearly searching
        /// </summary>
        public int FindElementIndexFromHash(IntPtr elementToFind)
        {
            IntPtr localElementPropForCapture = elementProp;

            HashDelegates.GetKeyHash elementHash = delegate(IntPtr elementKey)
            {
                return(Native_UProperty.GetValueTypeHash(localElementPropForCapture, elementKey));
            };
            HashDelegates.Equality elementEquality = delegate(IntPtr a, IntPtr b)
            {
                return(Native_UProperty.Identical(localElementPropForCapture, a, b, 0));
            };
            return(set->FindIndex(elementToFind, ref setLayout, elementHash, elementEquality));
        }
コード例 #4
0
        /// <summary>
        /// Adds the element to the set, returning true if the element was added, or false if the element was already present
        /// </summary>
        public void AddElement(IntPtr elementToAdd)
        {
            IntPtr localElementPropForCapture = elementProp;

            HashDelegates.GetKeyHash elementHash = delegate(IntPtr elementKey)
            {
                return(Native_UProperty.GetValueTypeHash(localElementPropForCapture, elementKey));
            };
            HashDelegates.Equality elementEquality = delegate(IntPtr a, IntPtr b)
            {
                return(Native_UProperty.Identical(localElementPropForCapture, a, b, 0));
            };
            HashDelegates.Construct elementConstruct = delegate(IntPtr newElement)
            {
                if (Native_UProperty.HasAnyPropertyFlags(localElementPropForCapture, EPropertyFlags.ZeroConstructor))
                {
                    FMemory.Memzero(newElement, Native_UProperty.GetSize(localElementPropForCapture));
                }
                else
                {
                    Native_UProperty.InitializeValue(localElementPropForCapture, newElement);
                }

                Native_UProperty.CopySingleValue(localElementPropForCapture, newElement, elementToAdd);
            };
            HashDelegates.Destruct elementDestruct = delegate(IntPtr element)
            {
                if (!Native_UProperty.HasAnyPropertyFlags(localElementPropForCapture, EPropertyFlags.IsPlainOldData | EPropertyFlags.NoDestructor))
                {
                    Native_UProperty.DestroyValue(localElementPropForCapture, element);
                }
            };
            set->Add(
                elementToAdd,
                ref setLayout,
                elementHash,
                elementEquality,
                elementConstruct,
                elementDestruct);
        }
コード例 #5
0
        /// <summary>
        /// Removes the element from the set
        /// </summary>
        public bool RemoveElement(IntPtr elementToRemove)
        {
            IntPtr localElementPropForCapture = elementProp;

            HashDelegates.GetKeyHash elementHash = delegate(IntPtr elementKey)
            {
                return(Native_UProperty.GetValueTypeHash(localElementPropForCapture, elementKey));
            };
            HashDelegates.Equality elementEquality = delegate(IntPtr a, IntPtr b)
            {
                return(Native_UProperty.Identical(localElementPropForCapture, a, b, 0));
            };
            int foundIndex = set->FindIndex(elementToRemove, ref setLayout, elementHash, elementEquality);

            if (foundIndex != -1)
            {
                RemoveAt(foundIndex);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
 public void Add(IntPtr element, ref FScriptSetLayout layout, HashDelegates.GetKeyHash getKeyHash, HashDelegates.Equality equalityFn,
                 HashDelegates.Construct constructFn, HashDelegates.Destruct destructFn)
 {
     Native_FScriptSet.Add(ref this, element, ref layout, getKeyHash, equalityFn, constructFn, destructFn);
 }
コード例 #7
0
 public int FindIndex(IntPtr element, ref FScriptSetLayout layout, HashDelegates.GetKeyHash getKeyHash, HashDelegates.Equality equalityFn)
 {
     return(Native_FScriptSet.FindIndex(ref this, element, ref layout, getKeyHash, equalityFn));
 }
コード例 #8
0
 public void Rehash(ref FScriptSetLayout layout, HashDelegates.GetKeyHash getKeyHash)
 {
     Native_FScriptSet.Rehash(ref this, ref layout, getKeyHash);
 }
コード例 #9
0
ファイル: FScriptMap.cs プロジェクト: yimengfan/USharp
 /// <summary>
 /// Finds the associated value from hash of Key, rather than linearly searching
 /// </summary>
 public IntPtr FindValue(IntPtr key, ref FScriptMapLayout layout, HashDelegates.GetKeyHash getKeyHash, HashDelegates.Equality keyEqualityFn)
 {
     return(Native_FScriptMap.FindValue(ref this, key, ref layout, getKeyHash, keyEqualityFn));
 }
コード例 #10
0
ファイル: FScriptMap.cs プロジェクト: yimengfan/USharp
 public void Rehash(ref FScriptMapLayout layout, HashDelegates.GetKeyHash getKeyHash)
 {
     Pairs.Rehash(ref layout.SetLayout, getKeyHash);
 }