public Enumerator(ListSlice <T> inList) { m_List = inList.m_Source; m_Count = inList.Length; m_Offset = inList.m_StartIndex; m_Index = -1; }
/// <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); }
/// <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); }
public bool Equals(ListSlice <T> other) { return(m_Source == other.m_Source && m_StartIndex == other.m_StartIndex && Length == other.Length); }