Exemplo n.º 1
0
 public Enumerator(ListSlice <T> inList)
 {
     m_List   = inList.m_Source;
     m_Count  = inList.Length;
     m_Offset = inList.m_StartIndex;
     m_Index  = -1;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the closest hit from the given raycast list, ignoring any with 0 or less distance.
        /// </summary>
        static public RaycastHit2D ClosestHitNonZero(ListSlice <RaycastHit2D> inList)
        {
            float        minDist = float.MaxValue;
            RaycastHit2D closest = default(RaycastHit2D);
            RaycastHit2D checking;

            for (int i = 0, length = inList.Length; i < length; ++i)
            {
                checking = inList[i];
                if (checking.distance > 0 && checking.distance < minDist)
                {
                    minDist = checking.distance;
                    closest = checking;
                }
            }

            return(closest);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the maximum-scoring element from the given list.
        /// </summary>
        static public T GetMaxElement <T>(ListSlice <T> inList, ScoreFunction <T> inDelegate)
        {
            T     maxVal   = default(T);
            float maxScore = float.MinValue;

            float score;
            T     element;

            for (int i = 0; i < inList.Length; ++i)
            {
                element = inList[i];
                score   = inDelegate(element);
                if (score > maxScore)
                {
                    maxScore = score;
                    maxVal   = element;
                }
            }

            return(maxVal);
        }
Exemplo n.º 4
0
 public bool Equals(ListSlice <T> other)
 {
     return(m_Source == other.m_Source &&
            m_StartIndex == other.m_StartIndex &&
            Length == other.Length);
 }