src/snac/data/AbstractData.php
/**
     * diff Array
     *
     * Goes through arrays of AbstractData and performs a diff.  It returns an array of
     * three different arrays: intersection (the shared components), first (the items
     * of the first not appearing in the second), and second (the items of the
     * second not appearing in the first).
     *
     * @param \snac\data\AbstractData[] $first first array
     * @param \snac\data\AbstractData[] $second second array
     * @param boolean $strict optional whether or not to check ID/Version/Operation
     * @return mixed[] An associative array of AbstractData[] with "intersection," "first," and "second" keys
     */
diff Array
Goes through arrays of AbstractData and performs a diff.  It returns an array of
three different arrays: intersection (the shared components), first (the items
of the first not appearing in the second), and second (the items of the
second not appearing in the first).


diff Array Goes through arrays of AbstractData and performs a diff . It returns an array of three different arrays : intersection ( the shared components ) first ( the items of the first not appearing in the second ) and second ( the items of the second not appearing in the first ) .
protected function diffArray($first, $second, $strict = true) {
        $return = array(
            "intersection" => array(),
            "first" => array(),
            "second" => array()
        );
        if ($first == null && $second == null)
            return $return;
        if ($first == null) {
            $return["second"] = $second;
            return $return;
        }
        if ($second == null) {
            $return["first"] = $first;
            return $return;
        }
        $tmp = array();
        foreach ($first as $data) {
            $seen = false;
            foreach ($second as $k => $odata) {
                if ($data != null && $data->equals($odata, $strict)
                        && !isset($tmp[$k])) {
                    $tmp[$k] = true;
                    $seen = true;
                    array_push($return["intersection"], $data);
                }
            }
            if (!$seen) {
                array_push($return["first"], $data);
            }
        }
        foreach ($second as $k => $odata) {
            if (!isset($tmp[$k])) {
                array_push($return["second"], $odata);
            }
        }
        return $return;
    }
protected function diffArray ( $ first , $ second , $ strict = true ) { $ return = array ( " intersection " => array ( ) , " first " => array ( ) , " second " => array ( ) ) ; if ( $ first == null && $ second == null ) return $ return ; if ( $ first == null ) { $ return [ " second " ] = $ second ; return $ return ; } if ( $ second == null ) { $ return [ " first " ] = $ first ; return $ return ; } $ tmp = array ( ) ; foreach ( $ first as $ data ) { $ seen = false ; foreach ( $ second as $ k => $ odata ) { if ( $ data != null && $ data -> equals ( $ odata , $ strict ) && ! isset ( $ tmp [ $ k ] ) ) { $ tmp [ $ k ] = true ; $ seen = true ; array_push ( $ return [ " intersection " ] , $ data ) ; } } if ( ! $ seen ) { array_push ( $ return [ " first " ] , $ data ) ; } } foreach ( $ second as $ k => $ odata ) { if ( ! isset ( $ tmp [ $ k ] ) ) { array_push ( $ return [ " second " ] , $ odata ) ; } } return $ return ; }
diff Array
 Goes through arrays of AbstractData and performs a diff.
diff Array Goes through arrays of AbstractData and performs a diff .
// in case there are duplicates in first // make use of our key-bitmap to not have an inner loop