import ExpandedPair from './ExpandedPair' ; export default class ExpandedRow { private readonly pairs : Array < ExpandedPair > ; private readonly rowNumber : number ; private readonly wasReversed : boolean ; constructor ( pairs , rowNumber , wasReversed ) { this . pairs = pairs ; this . rowNumber = rowNumber ; this . wasReversed = wasReversed ; } getPairs ( ) { return this . pairs ; } getRowNumber ( ) { return this . rowNumber ; } isReversed ( ) { return this . wasReversed ; } isEquivalent ( otherPairs ) { return this . checkEqualitity ( this , otherPairs ) ; } public toString ( ) { return '{ ' + this . pairs + ' }' ; } /**
     * Two rows are equal if they contain the same pairs in the same order.
     */ public equals ( o1 , o2 ) { if ( ! ( o1 instanceof ExpandedRow ) ) { return false ; } return this . checkEqualitity ( o1 , o2 ) && o1 . wasReversed === o2 . wasReversed ; } checkEqualitity ( pair1 , pair2 ) { if ( ! pair1 || ! pair2 ) return ; let result ; pair1 . forEach ( ( e1 , i ) => { pair2 . forEach ( e2 => { if ( e1 . getLeftChar ( ) . getValue ( ) === e2 . getLeftChar ( ) . getValue ( ) && e1 . getRightChar ( ) . getValue ( ) === e2 . getRightChar ( ) . getValue ( ) && e1 . getFinderPatter ( ) . getValue ( ) === e2 . getFinderPatter ( ) . getValue ( ) ) { result = true ; } } ) ; } ) ; return result ; } }