gnu.trove.procedure.TIntProcedure Java Examples

The following examples show how to use gnu.trove.procedure.TIntProcedure. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QuestEngine.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
public boolean onCanAct(final QuestEnv env, int templateId, final QuestActionType questActionType, final Object... objects) {
	if (questCanAct.containsKey(templateId)) {
		TIntArrayList questIds = questCanAct.get(templateId);
		return !questIds.forEach(new TIntProcedure() {

			@Override
			public boolean execute(int value) {
				QuestHandler questHandler = getQuestHandlerByQuestId(value);
				if (questHandler != null) {
					env.setQuestId(value);
					if (questHandler.onCanAct(env, questActionType, objects)) {
						return false; // Abort for
					}
				}
				return true;
			}
		});
	}
	return false;
}
 
Example #2
Source File: Feature2DHandler.java    From Juicebox with MIT License 6 votes vote down vote up
public List<Feature2D> getContainedFeatures(int chrIdx1, int chrIdx2, net.sf.jsi.Rectangle currentWindow) {
    final List<Feature2D> foundFeatures = new ArrayList<>();
    final String key = Feature2DList.getKey(chrIdx1, chrIdx2);

    if (featureRtrees.containsKey(key)) {
        featureRtrees.get(key).contains(
                currentWindow,      // the window in which we want to find all rectangles
                new TIntProcedure() {         // a procedure whose execute() method will be called with the results
                    public boolean execute(int i) {
                        Feature2D feature = loopList.get(key).get(i);
                        //System.out.println(feature.getChr1() + "\t" + feature.getStart1() + "\t" + feature.getStart2());
                        foundFeatures.add(feature);
                        return true;              // return true here to continue receiving results
                    }
                }
        );
    } else {
        System.err.println("returning all; key " + key + " not found contained");
        List<Feature2D> features = loopList.get(key);
        if (features != null) foundFeatures.addAll(features);
    }

    return foundFeatures;
}
 
Example #3
Source File: Feature2DHandler.java    From JuiceboxLegacy with MIT License 6 votes vote down vote up
public List<Feature2D> findContainedFeatures(int chrIdx1, int chrIdx2, net.sf.jsi.Rectangle currentWindow) {
    final List<Feature2D> foundFeatures = new ArrayList<Feature2D>();
    final String key = Feature2DList.getKey(chrIdx1, chrIdx2);

    if (featureRtrees.containsKey(key)) {

        featureRtrees.get(key).contains(
                currentWindow,      // the window in which we want to find all rectangles
                new TIntProcedure() {         // a procedure whose execute() method will be called with the results
                    public boolean execute(int i) {
                        Feature2D feature = allFeaturesAcrossGenome.get(key).get(i);
                        //System.out.println(feature.getChr1() + "\t" + feature.getStart1() + "\t" + feature.getStart2());
                        foundFeatures.add(feature);
                        return true;              // return true here to continue receiving results
                    }
                }
        );

    } else {
        List<Feature2D> features = allFeaturesAcrossGenome.get(key);
        if (features != null) foundFeatures.addAll(features);
    }

    return foundFeatures;
}
 
Example #4
Source File: Feature2DHandler.java    From JuiceboxLegacy with MIT License 5 votes vote down vote up
public List<Feature2D> findNearbyFeatures(MatrixZoomData zd, int chrIdx1, int chrIdx2, int x, int y, int n,
                                          double binOriginX, double binOriginY, double scale) {
    final List<Feature2D> foundFeatures = new ArrayList<Feature2D>();
    final String key = Feature2DList.getKey(chrIdx1, chrIdx2);

    if (featureRtrees.containsKey(key) && showLoops) {
        if (sparseFeaturePlottingEnabled) {
            final HiCGridAxis xAxis = zd.getXGridAxis();
            final HiCGridAxis yAxis = zd.getYGridAxis();


            featureRtrees.get(key).nearestN(
                    getGenomicPointFromXYCoordinate(x, y, xAxis, yAxis, binOriginX, binOriginY, scale),      // the point for which we want to find nearby rectangles
                    new TIntProcedure() {         // a procedure whose execute() method will be called with the results
                        public boolean execute(int i) {
                            Feature2D feature = allFeaturesAcrossGenome.get(key).get(i);
                            foundFeatures.add(feature);
                            return true;              // return true here to continue receiving results
                        }
                    },
                    n,                            // the number of nearby rectangles to find
                    Float.MAX_VALUE               // Don't bother searching further than this. MAX_VALUE means search everything
            );

        } else {
            foundFeatures.addAll(allFeaturesAcrossGenome.get(key));
        }
    }
    return foundFeatures;
}
 
Example #5
Source File: Feature2DHandler.java    From Juicebox with MIT License 5 votes vote down vote up
public List<Feature2D> getIntersectingFeatures(int chrIdx1, int chrIdx2, net.sf.jsi.Rectangle selectionWindow, boolean ignoreVisibility) {
    final List<Feature2D> foundFeatures = new ArrayList<>();
    final String key = Feature2DList.getKey(chrIdx1, chrIdx2);

    if (layerVisible || ignoreVisibility) {
        if (featureRtrees.containsKey(key)) {
            try {
                featureRtrees.get(key).intersects(
                        selectionWindow,
                        new TIntProcedure() {     // a procedure whose execute() method will be called with the results
                            public boolean execute(int i) {
                                Feature2D feature = loopList.get(key).get(i);
                                foundFeatures.add(feature);
                                return true;      // return true here to continue receiving results
                            }
                        });
                } catch (Exception e) {
                    System.err.println("Error encountered getting intersecting features" + e.getLocalizedMessage());
                }
        } else {
            System.err.println("returning all; didn't find " + key + " intersecting");
            List<Feature2D> features = loopList.get(key);
            if (features != null) foundFeatures.addAll(features);
        }
    }
    return foundFeatures;
}
 
Example #6
Source File: Feature2DHandler.java    From JuiceboxLegacy with MIT License 5 votes vote down vote up
public List<Pair<Rectangle, Feature2D>> findNearbyFeaturePairs(MatrixZoomData zd, int chrIdx1, int chrIdx2, int x, int y, int n,
                                                               final double binOriginX, final double binOriginY, final double scale) {

    final List<Pair<Rectangle, Feature2D>> featurePairs = new ArrayList<Pair<Rectangle, Feature2D>>();

    if (showLoops) {
        final String key = Feature2DList.getKey(chrIdx1, chrIdx2);

        final HiCGridAxis xAxis = zd.getXGridAxis();
        final HiCGridAxis yAxis = zd.getYGridAxis();

        if (featureRtrees.containsKey(key)) {
            featureRtrees.get(key).nearestN(
                    getGenomicPointFromXYCoordinate(x, y, xAxis, yAxis, binOriginX, binOriginY, scale),      // the point for which we want to find nearby rectangles
                    new TIntProcedure() {         // a procedure whose execute() method will be called with the results
                        public boolean execute(int i) {
                            Feature2D feature = allFeaturesAcrossGenome.get(key).get(i);
                            featurePairs.add(new Pair<Rectangle, Feature2D>(rectangleFromFeature(xAxis, yAxis, feature, binOriginX, binOriginY, scale), feature));
                            return true;              // return true here to continue receiving results
                        }
                    },
                    n,  // the number of nearby rectangles to find
                    Float.MAX_VALUE  // Don't bother searching further than this. MAX_VALUE means search everything
            );
        }
    }

    return featurePairs;
}
 
Example #7
Source File: TIntArrayList.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.list.array.TIntArrayList#forEachDescending(TIntProcedure)} */
public boolean forEachDescending(TIntProcedure procedure) {
  return delegate.forEachDescending(procedure);
}
 
Example #8
Source File: TIntArrayList.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.list.array.TIntArrayList#grep(TIntProcedure)} */
public TIntList grep(TIntProcedure condition) {
  return delegate.grep(condition);
}
 
Example #9
Source File: TIntArrayList.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.list.array.TIntArrayList#inverseGrep(TIntProcedure)} */
public TIntList inverseGrep(TIntProcedure condition) {
  return delegate.inverseGrep(condition);
}
 
Example #10
Source File: TIntIntHashMap.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.map.hash.TIntIntHashMap#forEach(TIntProcedure)} */
public boolean forEach(TIntProcedure procedure) {
  return delegate.forEach(procedure);
}
 
Example #11
Source File: TIntIntHashMap.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.map.hash.TIntIntHashMap#forEachKey(TIntProcedure)} */
public boolean forEachKey(TIntProcedure procedure) {
  return delegate.forEachKey(procedure);
}
 
Example #12
Source File: TIntIntHashMap.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.map.hash.TIntIntHashMap#forEachValue(TIntProcedure)} */
public boolean forEachValue(TIntProcedure procedure) {
  return delegate.forEachValue(procedure);
}
 
Example #13
Source File: TIntIntHashMapTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testForEach() {
  TIntProcedure procedure = i -> true;
  tIntIntHashMap.forEach(procedure);
  verify(delegate).forEach(procedure);
}
 
Example #14
Source File: TIntIntHashMapTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testForEachKey() {
  TIntProcedure procedure = i -> true;
  tIntIntHashMap.forEachKey(procedure);
  verify(delegate).forEachKey(procedure);
}
 
Example #15
Source File: TIntIntHashMapTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testForEachValue() {
  TIntProcedure procedure = i -> true;
  tIntIntHashMap.forEachValue(procedure);
  verify(delegate).forEachValue(procedure);
}
 
Example #16
Source File: TIntArrayListTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testForEach() {
  TIntProcedure procedure = i -> false;
  tIntArrayList.forEach(procedure);
  verify(delegate).forEach(procedure);
}
 
Example #17
Source File: TIntArrayListTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testForEachDescending() {
  TIntProcedure procedure = i -> false;
  tIntArrayList.forEachDescending(procedure);
  verify(delegate).forEachDescending(procedure);
}
 
Example #18
Source File: TIntArrayListTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testGrep() {
  TIntProcedure procedure = i -> true;
  tIntArrayList.grep(procedure);
  verify(delegate).grep(procedure);
}
 
Example #19
Source File: TIntArrayListTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void testInverseGrep() {
  TIntProcedure procedure = i -> true;
  tIntArrayList.inverseGrep(procedure);
  verify(delegate).inverseGrep(procedure);
}
 
Example #20
Source File: TIntArrayList.java    From baleen with Apache License 2.0 4 votes vote down vote up
/** See {@link gnu.trove.list.array.TIntArrayList#forEach(TIntProcedure)} */
public boolean forEach(TIntProcedure procedure) {
  return delegate.forEach(procedure);
}