import BitMatrix from '../../common/BitMatrix' ; export enum DataMaskValues { DATA_MASK_000 , DATA_MASK_001 , DATA_MASK_010 , DATA_MASK_011 , DATA_MASK_100 , DATA_MASK_101 , DATA_MASK_110 , DATA_MASK_111 } author Sean Owen
  export default class DataMask { public constructor ( private value , private isMasked ) { } public static values = new Map < DataMaskValues , DataMask > ( [ [ DataMaskValues . DATA_MASK_000 , new DataMask ( DataMaskValues . DATA_MASK_000 , ( i , j ) => { return ( ( i + j ) & 0x01 ) === 0 ; } ) ] , [ DataMaskValues . DATA_MASK_001 , new DataMask ( DataMaskValues . DATA_MASK_001 , ( i , j ) => { return ( i & 0x01 ) === 0 ; } ) ] , [ DataMaskValues . DATA_MASK_010 , new DataMask ( DataMaskValues . DATA_MASK_010 , ( i , j ) => { return j % 3 === 0 ; } ) ] , [ DataMaskValues . DATA_MASK_011 , new DataMask ( DataMaskValues . DATA_MASK_011 , ( i , j ) => { return ( i + j ) % 3 === 0 ; } ) ] , [ DataMaskValues . DATA_MASK_100 , new DataMask ( DataMaskValues . DATA_MASK_100 , ( i , j ) => { return ( ( Math . floor ( i / 2 ) + Math . floor ( j / 3 ) ) & 0x01 ) === 0 ; } ) ] , [ DataMaskValues . DATA_MASK_101 , new DataMask ( DataMaskValues . DATA_MASK_101 , ( i , j ) => { return ( i * j ) % 6 === 0 ; } ) ] , [ DataMaskValues . DATA_MASK_110 , new DataMask ( DataMaskValues . DATA_MASK_110 , ( i , j ) => { return ( ( i * j ) % 6 ) < 3 ; } ) ] , [ DataMaskValues . DATA_MASK_111 , new DataMask ( DataMaskValues . DATA_MASK_111 , ( i , j ) => { return ( ( i + j + ( ( i * j ) % 3 ) ) & 0x01 ) === 0 ; } ) ] , ] ) ; param bits param dimension public unmaskBitMatrix ( bits , dimension ) { for ( let i = 0 ; i < dimension ; i ++ ) { for ( let j = 0 ; j < dimension ; j ++ ) { if ( this . isMasked ( i , j ) ) { bits . flip ( j , i ) ; } } } } }