/// <summary> /// Reorganizes <see cref="AbstractChain"/> into <see cref="AbstractChain"/>. /// </summary> /// <param name="source"> /// Source chain. /// </param> /// <returns> /// The <see cref="AbstractChain"/>. /// </returns> public override AbstractChain Reorganize(AbstractChain source) { var resent = new BaseChain(source.GetLength()); for (int i = 0; i < source.GetLength(); i++) { var message = source[i] as ValuePhantom ?? new ValuePhantom { source[i] }; resent.Set(message, i); } return resent; }
/// <summary> /// Reorganizes <see cref="AbstractChain"/> into <see cref="AbstractChain"/>. /// </summary> /// <param name="source"> /// Source chain. /// </param> /// <returns> /// The <see cref="AbstractChain"/>. /// </returns> public override AbstractChain Reorganize(AbstractChain source) { var result = new BaseChain(); result.ClearAndSetNewLength(source.GetLength() / blockSize); IteratorBase iteratorFrom; IWritableIterator iteratorTo; if (link != Link.End) { iteratorFrom = new IteratorStart(source, blockSize, blockSize); iteratorTo = new IteratorWritableStart(result); } else { iteratorFrom = new IteratorEnd(source, blockSize, blockSize); iteratorTo = new IteratorWritableEnd(result); } while (iteratorTo.Next() && iteratorFrom.Next()) { iteratorTo.WriteValue(iteratorFrom.Current()); } return result; }
/// <summary> /// The cut common. /// </summary> /// <param name="chain"> /// Source sequence. /// </param> /// <returns> /// <see cref="double"/>. /// </returns> private double CutCommon(AbstractChain chain) { for (int length = 1; length <= chain.GetLength(); length++) { if (CheckRecoveryAvailable(chain, length)) { return length; } } return chain.GetLength(); }