/// <summary>
        ///   Determines whether this instance contains the specified item.
        /// </summary>
        ///
        /// <param name="item">The object to locate in the collection.
        ///   The value can be null for reference types.</param>
        ///
        /// <returns>
        ///   <c>true</c> if the item is found in the collection; otherwise, <c>false</c>.
        /// </returns>
        ///
        public bool Contains(KdTreeNodeDistance <T> item)
        {
            List <KDTreeNode <T> > position;

            if (_positions.TryGetValue(item.Distance, out position))
            {
                return(position.Contains(item.Node));
            }

            return(false);
        }
        /// <summary>
        ///   Removes the first occurrence of a specific object from the collection.
        /// </summary>
        ///
        /// <param name="item">The object to remove from the collection.
        /// The value can be null for reference types.</param>
        ///
        /// <returns>
        ///   <c>true</c> if item is successfully removed; otherwise, <c>false</c>.
        /// </returns>
        ///
        public bool Remove(KdTreeNodeDistance <T> item)
        {
            List <KDTreeNode <T> > position;

            if (!_positions.TryGetValue(item.Distance, out position))
            {
                return(false);
            }

            if (!position.Remove(item.Node))
            {
                return(false);
            }

            _range.Max = _distances.Max;
            _range.Min = _distances.Min;
            _count--;

            return(true);
        }
Exemplo n.º 3
0
 /// <summary>
 ///   Compares this instance to another node, returning an integer
 ///   indicating whether this instance has a distance that is less
 ///   than, equal to, or greater than the other node's distance.
 /// </summary>
 ///
 public int CompareTo(KdTreeNodeDistance <T> other)
 {
     return(_distance.CompareTo(other._distance));
 }
Exemplo n.º 4
0
 /// <summary>
 ///   Determines whether the specified <see cref="KdTreeNodeDistance{T}"/>
 ///   is equal to this instance.
 /// </summary>
 ///
 /// <param name="other">The <see cref="KdTreeNodeDistance{T}"/> to compare
 ///   with this instance.</param>
 ///
 /// <returns>
 ///   <c>true</c> if the specified <see cref="KdTreeNodeDistance{T}"/> is
 ///   equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 ///
 public bool Equals(KdTreeNodeDistance <T> other)
 {
     return(_distance == other._distance && _node == other._node);
 }
 /// <summary>
 ///   Adds the specified item to this collection.
 /// </summary>
 ///
 /// <param name="item">The item.</param>
 ///
 public void Add(KdTreeNodeDistance <T> item)
 {
     Add(item.Node, item.Distance);
 }