public bool ChangeRightWindowOffset(int offset, ElementSegmentPolicy Policy = ElementSegmentPolicy.Ignore) { //윈도우 경계를 변경 가능한 상태인지 확인 if ((offset == 0) || (IsFlexibleWindow == false) || (IsReadOnly == true)) { return(false); } throw new NotImplementedException(); int NextWindowSize = WindowSize + offset; int NextWindowRight = WindowOffset + NextWindowSize; //우측 윈도우 경계가 좌측 경계보다 작거나 세그먼트 소스의 길이보다 클 경우 if (NextWindowRight < WindowOffset || NextWindowRight > m_Segment.Array.Length) { throw new InvalidOperationException("전달된 Offset값으로 인해 조절된 윈도우의 상태가 비유효 하게 됬습니다."); } else { WindowSize = NextWindowSize; //정책에 따른 추가된 요소들에 대한 처리 Count += Math.Abs(offset); } return(true); }
/// <summary> /// 윈도우 왼쪽 경계를 조절합니다. /// </summary> /// <param name="offset"></param> /// <param name="policy"></param> public bool ChangeLeftWindowOffset(int offset, ElementSegmentPolicy policy = ElementSegmentPolicy.Ignore) { //윈도우 경계를 변경 가능한 상태인지 확인 if ((offset == 0) || (IsFlexibleWindow == false) || (IsReadOnly == true)) { return(false); } throw new NotImplementedException(); return(true); }
/// <summary> /// index부터 지정된 갯수까지의 Element들의 Offset만큼 이동시킵니다. /// 반환 값으로는 잘려 나가는 값들이 반환됩니다. /// 또한 우측으로 이동시 객체가 증가하여 Count가 증가할 수 있습니다. /// </summary> /// <param name="Index">이동의 기준점이 되는 index</param> /// <param name="count">객체의 수</param> /// <param name="offset">인덱스로 부터 이동할 Offset</param> /// <param name="policy"> /// 무시정책: 이동하면서 발생하는 빈공간의 데이터를 defalut(T)로 초기화합니다. /// 포함정책: 빈공간의 데이터를 기존 데이터로 인정합니다. /// </param> public ElementSegmentEventArgs <T> MoveElement(int index, int count, int offset, ElementSegmentPolicy policy = ElementSegmentPolicy.Ignore) { //interval [index, index + count) //이동 연산이 일어나지 않는 Arguement 확인 if ((count == 0) || (offset == 0)) { return(new ElementSegmentEventArgs <T>()); } //인덱스 유효 여부 if ((index < 0) || (index > WindowSize)) { throw new ArgumentOutOfRangeException("전달된 index가 유효 하지 않습니다."); } //무효객체 포함 여부 확인 후 Exception 발생 if ((index + count) > Count) { throw new ArgumentOutOfRangeException("전달된 범위가 비유효 객체를 포함하거나 혹은 윈도우 경계를 넘었습니다."); } ElementSegmentEventArgs <T> Args = new ElementSegmentEventArgs <T>(); Args.CutData = new List <T>(); Args.OverlapData = new List <T>(); int MovingReferencePoint; //이동되는 객체의 (좌 or 우) 마지막 최첨단을 가르킨다. int MoveMarker; //offset에 따른 이동 마커 - + List <int> DefalutIndexList = new List <int>(); //defalut(T)를 한 값들의 인덱스 집합 //이동 방향에 따른 이동마커 설정 및 우측 이동의 경우 Count 증가 여부 확인후 증가 if (offset < 0) { //좌측 MovingReferencePoint = (index + offset); MoveMarker = 1; //index = index; } else { //우측 // interval [index , index + count) 이동할 객체 중 우측 객체부터 차례로 이동해야한다. MovingReferencePoint = (index + count + offset); MoveMarker = -1; index = index + count - 1; Count = (MovingReferencePoint < WindowSize) ? (MovingReferencePoint) : (WindowSize); MovingReferencePoint -= 1; // index로 쓸려면 -1 } for (int i = 0; i < count; ++i) { //외부로 나가는 객체일 경우 if (MovingReferencePoint < 0 || MovingReferencePoint >= WindowSize) { Args.CutData.Add(this[index]); } else { //내부의 overlap 되는 경우. 이전단계 적용 값이 디폴트 값 적용한 상태가 아니여야함 if (DefalutIndexList.Contains(MovingReferencePoint) == false) { Args.OverlapData.Add(this[MovingReferencePoint]); } this[MovingReferencePoint] = this[index]; } //정책에 따른 처리, 초기화 된 값들은 초기화 리스트에 추가 if (policy == ElementSegmentPolicy.Ignore) { this[index] = default(T); DefalutIndexList.Add(index); } //마커 이동 index += MoveMarker; MovingReferencePoint += MoveMarker; } return(Args); }