modifies by intersecting with another intersection

@param arg another intersection
163600
public void intersectWith(Intersection<T> arg) {
		// if the argument is top then leave all as is
		if (arg.elements != null) {
			
			// if arg is empty, the result is empty
			if (arg.elements.isEmpty())
				elements = Collections.emptySet();
			else {
				if (elements == null) // we have top, the intersection is sub
					elements = new HashSet<>(arg.elements); // copy the set
				else
					elements.retainAll(arg.elements);							
			}
		}
	}
1250737
public static void main(String[] args) {
    Map<Integer,Integer> originalMap = new HashMap<Integer,Integer>();
    Random r = new Random();
    for (int i = 0; i < 1000; i++) {
      originalMap.put(Integer.valueOf(i), Integer.valueOf(r.nextInt(1000)));
    }
    Map<Integer,Integer> originalCopyMap = new HashMap<Integer,Integer>(originalMap);
    Map<Integer,Integer> deltaCopyMap = new HashMap<Integer,Integer>(originalMap);
    Map<Integer,Integer> deltaMap = new DeltaMap<Integer,Integer>(originalMap);
    // now make a lot of changes to deltaMap;
    // add and change some stuff
    for (int i = 900; i < 1100; i++) {
      Integer rInt = Integer.valueOf(r.nextInt(1000));
      deltaMap.put(Integer.valueOf(i), rInt);
      deltaCopyMap.put(Integer.valueOf(i), rInt);
    }
    // remove some stuff
    for (int i = 0; i < 100; i++) {
      Integer rInt = Integer.valueOf(r.nextInt(1100));
      deltaMap.remove(rInt);
      deltaCopyMap.remove(rInt);
    }
    // set some stuff to null
    for (int i = 0; i < 100; i++) {
      Integer rInt = Integer.valueOf(r.nextInt(1100));
      deltaMap.put(rInt, null);
      deltaCopyMap.put(rInt, null);
    }

    System.out.println("Original preserved? " + originalCopyMap.equals(originalMap));
    System.out.println("Delta accurate? " + deltaMap.equals(deltaCopyMap));
  }
141823
protected static boolean argIsOption(String arg, String option) {
        return arg.equalsIgnoreCase(option) || arg.equalsIgnoreCase('-' + option);
    }
429057
private static String[] shift(String[] args) {
    if(args==null || args.length==0 | args.length==1) return new String[0];
    String[] newArgs = new String[args.length-1];
    System.arraycopy(args, 1, newArgs, 0, newArgs.length);
    return newArgs;
  }
719869
def add_arg(self,arg, prepend=False):
        """"""

        self.args = [arg_.strip() for arg_ in self.args if arg_.strip()]

        if arg.title() not in self.args:
            if prepend:
                self.args = [arg.title()] + self.args
            else:
                self.args.append(arg.title())
1345230
public void intersection(Formats other, Formats intersection) {
        intersection.list.clear();
        for (Format f1 : list) {
            for (Format f2 : other.list) {
                if (f1.matches(f2)) intersection.list.add(f2);
            }
        }
    }
404516
function boxIntersectWrapper(arg0, arg1, arg2) {
  var result
  switch(arguments.length) {
    case 1:
      return intersectFullArray(arg0)
    case 2:
      if(typeof arg1 === 'function') {
        return boxIntersect(arg0, arg0, arg1, true)
      } else {
        return intersectBipartiteArray(arg0, arg1)
      }
    case 3:
      return boxIntersect(arg0, arg1, arg2, false)
    default:
      throw new Error('box-intersect: Invalid arguments')
  }
}
622376
function setOption(arg)
{
  arg = arg.split('=')

  var key, value

  if(arg.length > 1)
  {
    key   = arg.shift()
    value = arg.join('=')
  }
  else
  {
    key = arg
    value = true
  }

  this[key] = value
}
1152774
def intersection(self, *args):
        '''
        '''
        values = self.values()
        if args:
            values = [val for key,val in self.items() if key in args]
        return set(reduce(set.intersection, values))
663394
public static void main(String[] args) {
        // Multithreaded map rendering
        Parameters.NUMBER_OF_THREADS = 2;

        // Square frame buffer
        Parameters.SQUARE_FRAME_BUFFER = false;

        HillsRenderConfig hillsCfg = null;
        File demFolder = getDemFolder(args);
        if (demFolder != null) {
            MemoryCachingHgtReaderTileSource tileSource = new MemoryCachingHgtReaderTileSource(demFolder, new DiffuseLightShadingAlgorithm(), AwtGraphicFactory.INSTANCE);
            tileSource.setEnableInterpolationOverlap(true);
            hillsCfg = new HillsRenderConfig(tileSource);
            hillsCfg.indexOnThread();
            args = Arrays.copyOfRange(args, 1, args.length);
        }

        List<File> mapFiles = SHOW_RASTER_MAP ? null : getMapFiles(args);
        final MapView mapView = createMapView();
        final BoundingBox boundingBox = addLayers(mapView, mapFiles, hillsCfg);

        final PreferencesFacade preferencesFacade = new JavaPreferences(Preferences.userNodeForPackage(Samples.class));

        final JFrame frame = new JFrame();
        frame.setTitle("Mapsforge Samples");
        frame.add(mapView);
        frame.pack();
        frame.setSize(1024, 768);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                int result = JOptionPane.showConfirmDialog(frame, MESSAGE, TITLE, JOptionPane.YES_NO_OPTION);
                if (result == JOptionPane.YES_OPTION) {
                    mapView.getModel().save(preferencesFacade);
                    mapView.destroyAll();
                    AwtGraphicFactory.clearResourceMemoryCache();
                    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                }
            }

            @Override
            public void windowOpened(WindowEvent e) {
                final Model model = mapView.getModel();
                model.init(preferencesFacade);
                if (model.mapViewPosition.getZoomLevel() == 0 || !boundingBox.contains(model.mapViewPosition.getCenter())) {
                    byte zoomLevel = LatLongUtils.zoomForBounds(model.mapViewDimension.getDimension(), boundingBox, model.displayModel.getTileSize());
                    model.mapViewPosition.setMapPosition(new MapPosition(boundingBox.getCenterPoint(), zoomLevel));
                }
            }
        });
        frame.setVisible(true);
    }
367868
public static void main(String[] args) {
    CollectionValuedMap<Integer, Integer> originalMap = new CollectionValuedMap<Integer, Integer>();
    /*
        for (int i=0; i<4; i++) {
          for (int j=0; j<4; j++) {
            originalMap.add(new Integer(i), new Integer(j));
          }
        }
        originalMap.remove(new Integer(2));
        System.out.println("Map: ");
        System.out.println(originalMap);
        System.exit(0);
    */
    Random r = new Random();
    for (int i = 0; i < 800; i++) {
      Integer rInt1 = Integer.valueOf(r.nextInt(400));
      Integer rInt2 = Integer.valueOf(r.nextInt(400));
      originalMap.add(rInt1, rInt2);
      System.out.println("Adding " + rInt1 + ' ' + rInt2);
    }
    CollectionValuedMap<Integer, Integer> originalCopyMap = new CollectionValuedMap<Integer, Integer>(originalMap);
    CollectionValuedMap<Integer, Integer> deltaCopyMap = new CollectionValuedMap<Integer, Integer>(originalMap);
    CollectionValuedMap<Integer, Integer> deltaMap = new DeltaCollectionValuedMap<Integer, Integer>(originalMap);
    // now make a lot of changes to deltaMap;
    // add and change some stuff
    for (int i = 0; i < 400; i++) {
      Integer rInt1 = Integer.valueOf(r.nextInt(400));
      Integer rInt2 = Integer.valueOf(r.nextInt(400) + 1000);
      deltaMap.add(rInt1, rInt2);
      deltaCopyMap.add(rInt1, rInt2);
      System.out.println("Adding " + rInt1 + ' ' + rInt2);
    }
    // remove some stuff
    for (int i = 0; i < 400; i++) {
      Integer rInt1 = Integer.valueOf(r.nextInt(1400));
      Integer rInt2 = Integer.valueOf(r.nextInt(1400));
      deltaMap.removeMapping(rInt1, rInt2);
      deltaCopyMap.removeMapping(rInt1, rInt2);
      System.out.println("Removing " + rInt1 + ' ' + rInt2);
    }
    System.out.println("original: " + originalMap);
    System.out.println("copy: " + deltaCopyMap);
    System.out.println("delta: " + deltaMap);

    System.out.println("Original preserved? " + originalCopyMap.equals(originalMap));
    System.out.println("Delta accurate? " + deltaMap.equals(deltaCopyMap));
  }
485820
def intersection(*args):
    
    if not args:
        return []

    # remove duplicates from first list whilst preserving order
    base = list(OrderedDict.fromkeys(args[0]))

    if len(args) == 1:
        return base
    else:
        others = set(args[1]).intersection(*args[2:])
        return [e for e in base if e in others]
387272
public static VectorFunction asMinusFunction(final double arg) {
        return new VectorFunction() {
            @Override
            public double evaluate(int i, double value) {
                return value - arg;
            }
        };
    }
1287191
public void setArgs(String argString)
  {
    try {
      if (argString != null) {
        String []args = Pattern.compile("[\\s,]+").split(argString);

        _args = new ArrayList<String>();

        for (int i = 0; i < args.length; i++) {
          if (! args[i].equals(""))
            _args.add(args[i]);
        }
      }
    } catch (Exception e) {
      log.log(Level.WARNING, e.toString(), e);
    }
  }
222090
public void enterLambdaScope(Map<String,Object> args) {
        if (lambdaArgs == null) {
            lambdaArgs = new Stack<Map<String,Object>>();
        }
        lambdaArgs.push(args);
    }
743231
protected void addArg(Object value) {
        if (value instanceof Enum) {
            value = ((Enum<?>) value).name();
        }
        args.add(value);
    }
440157
public static String print(Arg arg) {
        return printArgModifiers(arg.modifiers) + print(arg.type) + " " + arg.name;
    }