コード例 #1
0
        internal NativeMappedAggregator(int capacity, Allocator allocator, TAggregator shell = default)
        {
            CollectionHelper.CheckIsUnmanaged <TKey>();
            CollectionHelper.CheckIsUnmanaged <TData>();
            mAllocator = allocator;
            // Bucket size is bigger to reduce collisions
            UnsafeHashMapData.AllocateHashMap <TKey, TData>(capacity, capacity << 1, allocator, out mBuffer);
            UnsafeHashMapBase <TKey, TData> .Clear(mBuffer);

            mShell = shell;
        }
コード例 #2
0
 /// <summary>
 /// Add an element with the specified key and value into the container.
 /// </summary>
 /// <param name="key">The key of the element to add.</param>
 /// <param name="item">The value of the element to add.</param>
 public void Add(TKey key, TValue item)
 {
     UnsafeHashMapBase <TKey, TValue> .TryAdd(m_Buffer, key, item, true, m_AllocatorLabel);
 }
コード例 #3
0
 /// <summary>
 /// Clears the container.
 /// </summary>
 /// <remarks>Containers capacity remains unchanged.</remarks>
 public void Clear()
 {
     UnsafeHashMapBase <TKey, TValue> .Clear(m_Buffer);
 }
コード例 #4
0
 /// <summary>
 /// Add an element with the specified key and value into the container.
 /// </summary>
 /// <param name="key">The key of the element to add.</param>
 /// <param name="item">The value of the element to add.</param>
 public void Add(TKey key, TValue item)
 {
     Assert.IsTrue(m_ThreadIndex >= 0);
     UnsafeHashMapBase <TKey, TValue> .AddAtomicMulti(m_Buffer, key, item, m_ThreadIndex);
 }
コード例 #5
0
 /// <summary>
 /// Replace value at iterator.
 /// </summary>
 /// <param name="item">Value.</param>
 /// <param name="it">Iterator</param>
 /// <returns>Returns true if value was sucessfuly replaced.</returns>
 public bool SetValue(TValue item, NativeMultiHashMapIterator <TKey> it)
 {
     return(UnsafeHashMapBase <TKey, TValue> .SetValue(m_Buffer, ref it, ref item));
 }
コード例 #6
0
 /// <summary>
 /// Retrieve iterator to the next value for the key.
 /// </summary>
 /// <param name="item">Output value.</param>
 /// <param name="it">Iterator.</param>
 /// <returns>Returns true if next value for the key is found.</returns>
 public bool TryGetNextValue(out TValue item, ref NativeMultiHashMapIterator <TKey> it)
 {
     return(UnsafeHashMapBase <TKey, TValue> .TryGetNextValueAtomic(m_Buffer, out item, ref it));
 }
コード例 #7
0
 /// <summary>
 /// Retrieve iterator for the first value for the key.
 /// </summary>
 /// <param name="key">The key.</param>
 /// <param name="item">Output value.</param>
 /// <param name="it">Iterator.</param>
 /// <returns>Returns true if the container contains the key.</returns>
 public bool TryGetFirstValue(TKey key, out TValue item, out NativeMultiHashMapIterator <TKey> it)
 {
     return(UnsafeHashMapBase <TKey, TValue> .TryGetFirstValueAtomic(m_Buffer, key, out item, out it));
 }
コード例 #8
0
 /// <summary>
 /// Removes all elements with the specified iterator the container.
 /// </summary>
 /// <param name="it">Iterator pointing at value to remove.</param>
 public void Remove(NativeMultiHashMapIterator <TKey> it)
 {
     UnsafeHashMapBase <TKey, TValue> .Remove(m_Buffer, it);
 }
コード例 #9
0
 public void Remove <TValueEQ>(TKey key, TValueEQ value)
     where TValueEQ : struct, IEquatable <TValueEQ>
 {
     UnsafeHashMapBase <TKey, TValueEQ> .RemoveKeyValue(m_Buffer, key, value);
 }
コード例 #10
0
 /// <summary>
 /// Removes all elements with the specified key from the container.
 /// </summary>
 /// <param name="key">The key of the element to remove.</param>
 /// <returns>Returns number of removed items.</returns>
 public int Remove(TKey key)
 {
     return(UnsafeHashMapBase <TKey, TValue> .Remove(m_Buffer, key, true));
 }