浏览代码

renamed OrderedSet to LinkedHashSet

/main
Steven Leal 4 年前
当前提交
2f722cc5
共有 4 个文件被更改,包括 7 次插入7 次删除
  1. 6
      com.unity.perception/Runtime/Randomization/Randomizers/RandomizerTagManager.cs
  2. 8
      com.unity.perception/Runtime/Randomization/Randomizers/LinkedHashSet.cs
  3. 0
      /com.unity.perception/Runtime/Randomization/Randomizers/LinkedHashSet.cs.meta
  4. 0
      /com.unity.perception/Runtime/Randomization/Randomizers/LinkedHashSet.cs

6
com.unity.perception/Runtime/Randomization/Randomizers/RandomizerTagManager.cs


public static RandomizerTagManager singleton { get; } = new RandomizerTagManager();
Dictionary<Type, HashSet<Type>> m_TypeTree = new Dictionary<Type, HashSet<Type>>();
Dictionary<Type, OrderedSet<RandomizerTag>> m_TagMap = new Dictionary<Type, OrderedSet<RandomizerTag>>();
Dictionary<Type, LinkedHashSet<RandomizerTag>> m_TagMap = new Dictionary<Type, LinkedHashSet<RandomizerTag>>();
/// <summary>
/// Enumerates over all RandomizerTags of the given type present in the scene

if (m_TypeTree.ContainsKey(tagType))
return;
m_TagMap.Add(tagType, new OrderedSet<RandomizerTag>());
m_TagMap.Add(tagType, new LinkedHashSet<RandomizerTag>());
m_TypeTree.Add(tagType, new HashSet<Type>());
var baseType = tagType.BaseType;

{
m_TagMap.Add(baseType, new OrderedSet<RandomizerTag>());
m_TagMap.Add(baseType, new LinkedHashSet<RandomizerTag>());
m_TypeTree[baseType] = new HashSet<Type> { tagType };
}
else

8
com.unity.perception/Runtime/Randomization/Randomizers/LinkedHashSet.cs


/// O(1) lookup, O(1) insertion, O(1) removal, and O(n) traversal
/// </summary>
/// <typeparam name="T">The item type to store in this collection</typeparam>
class OrderedSet<T> : ICollection<T>
class LinkedHashSet<T> : ICollection<T>
public OrderedSet() : this(EqualityComparer<T>.Default) { }
public LinkedHashSet() : this(EqualityComparer<T>.Default) { }
public OrderedSet(IEqualityComparer<T> comparer)
public LinkedHashSet(IEqualityComparer<T> comparer)
{
m_Dictionary = new Dictionary<T, LinkedListNode<T>>(comparer);
m_LinkedList = new LinkedList<T>();

public virtual bool IsReadOnly => m_Dictionary.IsReadOnly;
public bool IsReadOnly => m_Dictionary.IsReadOnly;
void ICollection<T>.Add(T item)
{

/com.unity.perception/Runtime/Randomization/Randomizers/OrderedSet.cs.meta → /com.unity.perception/Runtime/Randomization/Randomizers/LinkedHashSet.cs.meta

/com.unity.perception/Runtime/Randomization/Randomizers/OrderedSet.cs → /com.unity.perception/Runtime/Randomization/Randomizers/LinkedHashSet.cs

正在加载...
取消
保存