/// <summary>現在位置から前方へ指定した距離だけ移動可能な場合は移動する。</summary> /// <typeparam name="T">要素の型</typeparam> /// <param name="scroller">対象インスタンス</param> /// <param name="count">距離</param> /// <returns>結果</returns> public static ResultWithValue <IElementScroller <T> > MaybePrevious <T>(this IElementScroller <T> scroller, int count) { if (scroller.HasPrevious(count)) { return(new ResultWithValue <IElementScroller <T> >(scroller.Previous(count))); } else { return(new ResultWithValue <IElementScroller <T> >(false, scroller)); } }
/// <summary>現在位置より前方に条件を満たす要素が存在した場合はその位置へ移動する。</summary> /// <typeparam name="T">要素の型</typeparam> /// <param name="scroller">対象インスタンス</param> /// <param name="predicate">条件</param> /// <returns>結果</returns> public static ResultWithValue <IElementScroller <T> > MaybePrevious <T>(this IElementScroller <T> scroller, Predicate <T> predicate) { if (scroller.HasPrevious(predicate)) { return(new ResultWithValue <IElementScroller <T> >(scroller.Previous(predicate))); } else { return(new ResultWithValue <IElementScroller <T> >(false, scroller)); } }
/// <summary>現在の位置の名に要素が存在するかどうかを示す値を取得する。</summary> /// <typeparam name="T">要素の型</typeparam> /// <param name="scroller">対象インスタンス</param> public static bool HasPrevious <T>(this IElementScroller <T> scroller) { return(scroller.HasPrevious(1)); }