示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="itemComparer">
        /// Equality comparer to use for comparison and hashing of type T. Be especially mindful of the
        /// efficiency of its GetHashCode function, as it will determine the efficiency of many AdvancedMultiSpatialMap
        /// functions.
        /// </param>
        /// <param name="listPool">
        /// The list pool implementation to use.  Specify <see cref="NoPoolingListPool{T}"/> to disable pooling entirely.
        /// This implementation _may_ be shared with other spatial maps if you wish, however be aware that no thread safety is implemented
        /// by the default list pool implementations or the spatial map itself.
        /// </param>
        /// <param name="pointComparer">
        /// Equality comparer to use for comparison and hashing of points, as object are added to/removed from/moved
        /// around the spatial map.  Be especially mindful of the efficiency of its GetHashCode function, as it will
        /// determine the efficiency of many AdvancedMultiSpatialMap functions.  Defaults to the default equality
        /// comparer for Point, which uses a fairly efficient generalized hashing algorithm.
        /// </param>
        /// <param name="initialCapacity">
        /// The initial maximum number of elements the AdvancedMultiSpatialMap can hold before it has to
        /// internally resize data structures. Defaults to 32.
        /// </param>
        public AdvancedMultiSpatialMap(IEqualityComparer <T> itemComparer, IListPool <T> listPool,
                                       IEqualityComparer <Point>?pointComparer = null,
                                       int initialCapacity = 32)
        {
            _itemMapping     = new Dictionary <T, Point>(initialCapacity, itemComparer);
            _positionMapping = new Dictionary <Point, List <T> >(initialCapacity, pointComparer ?? EqualityComparer <Point> .Default);

            _itemListPool = listPool;
        }
示例#2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="listPool">
 /// The list pool implementation to use.  Specify <see cref="NoPoolingListPool{T}"/> to disable pooling entirely.
 /// This implementation _may_ be shared with other spatial maps if you wish, however be aware that no thread safety is implemented
 /// by the default list pool implementations or the spatial map itself.
 /// </param>
 /// <param name="pointComparer">
 /// Equality comparer to use for comparison and hashing of points, as object are added to/removed from/moved
 /// around the spatial map.  Be especially mindful of the efficiency of its GetHashCode function, as it will
 /// determine the efficiency of many MultiSpatialMap functions.  Defaults to the default equality
 /// comparer for Point, which uses a fairly efficient generalized hashing algorithm.
 /// </param>
 /// <param name="initialCapacity">
 /// The initial maximum number of elements the spatial map can hold before it has to
 /// internally resize data structures. Defaults to 32.
 /// </param>
 public MultiSpatialMap(IListPool <T> listPool, IEqualityComparer <Point>?pointComparer = null, int initialCapacity = 32)
     : base(new IDComparer <T>(), listPool, pointComparer, initialCapacity)
 {
 }