public function contains()
    {

        // build new set from passed arguments
        $reflection = new \ReflectionClass( get_called_class() );
        $comparing = $reflection->newInstanceArgs( func_get_args() );

        // we don't have a null but the set we're comparing against has it
        if( !$this->containsNull and $comparing->containsNull ) {
            return false;
        }

        reset( $this->intervals );
        reset( $comparing->intervals );

        list(,$compare) = each($comparing->intervals);
        list(,$current) = each($this->intervals);

        while( $compare and $current) {

            // Intervals are maximal. They're either entirely contained or not at all
            if( $compare[0] !== null and $this->sort( $compare[0], $current[1], self::NULL_IS_HIGH ) > 0 ) {
                list(,$current) = each($this->intervals);
                continue;
            }

            // are intervals contained?
            if(
                // compare lower is >= current lower
                $this->sort( $compare[0], $current[0], self::NULL_IS_LOW ) >= 0 and
                // compare upper is <= current upper
                $this->sort( $compare[1], $current[1], self::NULL_IS_HIGH ) <= 0
            ) {

                list(,$compare) = each($comparing->intervals);

            // interval can't be contained
            } else {

                return false;

            }

        }

        // if we're still got something to comparing something we've not been able to match it up with a interval
        return !$compare;

    }
public function contains()
    {

        // build new set from passed arguments
        $reflection = new \ReflectionClass( get_called_class() );
        $comparing = $reflection->newInstanceArgs( func_get_args() );

        // we don't have a null but the set we're comparing against has it
        if( !$this->containsNull and $comparing->containsNull ) {
            return false;
        }

        reset( $this->intervals );
        reset( $comparing->intervals );

        list(,$compare) = each($comparing->intervals);
        list(,$current) = each($this->intervals);

        while( $compare and $current) {

            // Intervals are maximal. They're either entirely contained or not at all
            if( $compare[0] !== null and $this->sort( $compare[0], $current[1], self::NULL_IS_HIGH ) > 0 ) {
                list(,$current) = each($this->intervals);
                continue;
            }

            // are intervals contained?
            if(
                // compare lower is >= current lower
                $this->sort( $compare[0], $current[0], self::NULL_IS_LOW ) >= 0 and
                // compare upper is <= current upper
                $this->sort( $compare[1], $current[1], self::NULL_IS_HIGH ) <= 0
            ) {

                list(,$compare) = each($comparing->intervals);

            // interval can't be contained
            } else {

                return false;

            }

        }

        // if we're still got something to comparing something we've not been able to match it up with a interval
        return !$compare;

    }
public function contains ( ) { // build new set from passed arguments $ reflection = new \ ReflectionClass ( get_called_class ( ) ) ; $ comparing = $ reflection -> newInstanceArgs ( func_get_args ( ) ) ; // we don't have a null but the set we're comparing against has it if ( ! $ this -> containsNull and $ comparing -> containsNull ) { return false ; } reset ( $ this -> intervals ) ; reset ( $ comparing -> intervals ) ; list ( , $ compare ) = each ( $ comparing -> intervals ) ; list ( , $ current ) = each ( $ this -> intervals ) ; while ( $ compare and $ current ) { // Intervals are maximal. They're either entirely contained or not at all if ( $ compare [ 0 ] !== null and $ this -> sort ( $ compare [ 0 ] , $ current [ 1 ] , self :: NULL_IS_HIGH ) > 0 ) { list ( , $ current ) = each ( $ this -> intervals ) ; continue ; } // are intervals contained? if ( // compare lower is >= current lower $ this -> sort ( $ compare [ 0 ] , $ current [ 0 ] , self :: NULL_IS_LOW ) >= 0 and // compare upper is <= current upper $ this -> sort ( $ compare [ 1 ] , $ current [ 1 ] , self :: NULL_IS_HIGH ) <= 0 ) { list ( , $ compare ) = each ( $ comparing -> intervals ) ; // interval can't be contained } else { return false ; } } // if we're still got something to comparing something we've not been able to match it up with a interval return ! $ compare ; }
Is a set contained within another set
@return <type>
Is a set contained within another set