java.util.TreeMap#floorEntry ( )源码实例Demo

下面列出了java.util.TreeMap#floorEntry ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: clearvolume   文件: TimeShiftingSink.java
private Volume getVolumeToSend(int pVolumeChannelID)
{
	synchronized (mLock)
	{
		final TreeMap<Long, SwitchableSoftReference<Volume>> lTimePointIndexToVolumeMap = mChannelToVolumeListsMap.get(pVolumeChannelID);

		if (lTimePointIndexToVolumeMap.isEmpty())
			return null;

		Entry<Long, SwitchableSoftReference<Volume>> lIndexVolumeEntry = lTimePointIndexToVolumeMap.floorEntry(mHighestTimePointIndexSeen + mTimeShift);
		if (lIndexVolumeEntry == null)
			lIndexVolumeEntry = lTimePointIndexToVolumeMap.ceilingEntry(mHighestTimePointIndexSeen + mTimeShift);

		if (lIndexVolumeEntry == null)
			return null;

		final Volume lVolume = lIndexVolumeEntry.getValue().get();
		if (lVolume == null)
		{
			lTimePointIndexToVolumeMap.remove(lIndexVolumeEntry.getKey());
			return getVolumeToSend(pVolumeChannelID);
		}
		return lVolume;
	}
}
 
源代码2 项目: dss   文件: CryptographicConstraintWrapper.java
public Date getExpirationDate(String algoToSearch, Integer keyLength) {
	TreeMap<Integer, Date> dates = new TreeMap<>();
	AlgoExpirationDate expirations = constraint.getAlgoExpirationDate();
	if (expirations == null) {
		return null;
	}
	SimpleDateFormat dateFormat = new SimpleDateFormat(Utils.isStringEmpty(expirations.getFormat()) ? DEFAULT_DATE_FORMAT : expirations.getFormat());

	for (Algo algo : expirations.getAlgo()) {
		if (algo.getValue().equals(algoToSearch)) {
			String expirationDate = algo.getDate();
			try {
				dates.put(algo.getSize(), dateFormat.parse(expirationDate));
			} catch (ParseException e) {
				LOG.warn("Unable to parse '{}' with format '{}'", expirationDate, dateFormat);
			}
		}
	}

	Entry<Integer, Date> floorEntry = dates.floorEntry(keyLength);
	if (floorEntry == null) {
		return null;
	} else {
		return floorEntry.getValue();
	}
}
 
源代码3 项目: EdgeCloudSim   文件: NomadicMobility.java
@Override
public Location getLocation(int deviceId, double time) {
	TreeMap<Double, Location> treeMap = treeMapArray.get(deviceId);
	
	Entry<Double, Location> e = treeMap.floorEntry(time);
    
    if(e == null){
    	SimLogger.printLine("impossible is occured! no location is found for the device '" + deviceId + "' at " + time);
    	System.exit(0);
    }
    
	return e.getValue();
}
 
源代码4 项目: openjdk-jdk9   文件: TreeMapTest.java
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    TreeMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
源代码5 项目: j2objc   文件: TreeMapTest.java
/**
 * floorEntry returns preceding entry.
 */
public void testFloorEntry() {
    TreeMap map = map5();
    Map.Entry e1 = map.floorEntry(three);
    assertEquals(three, e1.getKey());

    Map.Entry e2 = map.floorEntry(six);
    assertEquals(five, e2.getKey());

    Map.Entry e3 = map.floorEntry(one);
    assertEquals(one, e3.getKey());

    Map.Entry e4 = map.floorEntry(zero);
    assertNull(e4);
}
 
源代码6 项目: render   文件: ChannelSpec.java
public Map.Entry<Integer, ImageAndMask> getFloorMipmapEntry(final Integer mipmapLevel,
                                                            final TreeMap<Integer, ImageAndMask> levelToImageMap) {

    Map.Entry<Integer, ImageAndMask> floorEntry = levelToImageMap.floorEntry(mipmapLevel);

    if (floorEntry == null) {
        floorEntry = levelToImageMap.firstEntry();
    } else if ((floorEntry.getKey() < mipmapLevel) && (mipmapPathBuilder != null)) {
        floorEntry = mipmapPathBuilder.deriveImageAndMask(mipmapLevel,
                                                          levelToImageMap.firstEntry(),
                                                          true);
    }

    return floorEntry;
}
 
源代码7 项目: pumpernickel   文件: MemoryBranch.java
@Override
public BeanState getState(K beanId, Revision revision) {
	if (beanId == null)
		throw new NullPointerException();
	if (revision != null && revision.getBranch() != this)
		throw new IllegalRevisionBranchException(
				"The revision provided relates to branch \""
						+ revision.getBranch().getName() + "\" (not \""
						+ getName() + "\"", this, revision);

	Lock lock = acquireReadLock();
	try {
		Map<String, TreeMap<Revision, Object>> beanData = dataByBeanId
				.get(beanId);
		TreeMap<Revision, Object> deletedField = beanData == null ? null
				: beanData.get(FIELD_DELETED.toString());
		TreeMap<Revision, Object> createdField = beanData == null ? null
				: beanData.get(FIELD_CREATED.toString());

		if (revision == null)
			revision = currentRevision;

		int thresholdSize = beanData == null ? 0 : beanData.size();
		if (deletedField != null)
			thresholdSize--;
		if (createdField != null)
			thresholdSize--;
		boolean exists = beanData != null
				&& beanData.size() > thresholdSize;

		Entry<Revision, Object> deletedFloor = deletedField == null ? null
				: deletedField.floorEntry(revision);
		Entry<Revision, Object> createdFloor = createdField == null ? null
				: createdField.floorEntry(revision);

		if (deletedFloor == null && createdFloor == null) {
			// this branch neither created nor deleted this bean
			if (exists)
				return BeanState.EXISTS;
			if (parent != null) {
				BeanState returnValue = parent.getState(beanId,
						parentRevision);
				if (returnValue == BeanState.CREATED)
					returnValue = BeanState.EXISTS;
				return returnValue;
			} else {
				return BeanState.UNDEFINED;
			}
		} else if (deletedFloor == null && createdFloor != null) {
			return BeanState.CREATED;
		} else if (deletedFloor != null && createdFloor == null) {
			return BeanState.DELETED;
		} else {
			if (deletedFloor.getKey().compareTo(createdFloor.getKey()) < 0) {
				return BeanState.CREATED;
			}
			return BeanState.DELETED;
		}

	} finally {
		releaseLock(lock);
	}
}
 
源代码8 项目: gpx-animator   文件: Renderer.java
private Point2D drawMarker(final BufferedImage bi, final int frame) {
    if (cfg.getMarkerSize() == null || cfg.getMarkerSize() == 0.0) {
        return null;
    }

    Point2D point = null;

    final Graphics2D g2 = getGraphics(bi);
    final long t2 = getTime(frame);
    final List<TrackConfiguration> trackConfigurationList = cfg.getTrackConfigurationList();

    int i = 0;
    outer:
    for (final List<TreeMap<Long, Point2D>> timePointMapList : timePointMapListList) {
        final TrackConfiguration trackConfiguration = trackConfigurationList.get(i++);
        for (final TreeMap<Long, Point2D> timePointMap : timePointMapList) {
            final Entry<Long, Point2D> ceilingEntry = timePointMap.ceilingEntry(t2);
            final Entry<Long, Point2D> floorEntry = timePointMap.floorEntry(t2);
            if (floorEntry == null) {
                continue;
            }

            point = floorEntry.getValue();
            if (t2 - floorEntry.getKey() <= cfg.getTailDuration()) {

                g2.setColor(ceilingEntry == null ? Color.white : trackConfiguration.getColor());

                final TrackIcon trackIcon = trackConfiguration.getTrackIcon();
                if (trackIcon == null || trackIcon.getKey().isEmpty()) {
                    drawSimpleCircleOnGraphics2D(point, g2);
                } else {
                    try {
                        drawIconOnGraphics2D(point, g2, trackIcon);
                    } catch (final IOException e) {
                        drawSimpleCircleOnGraphics2D(point, g2);
                    }
                }

                final String label = trackConfiguration.getLabel();
                if (!label.isEmpty()) {
                    printText(g2, label, (float) point.getX() + 8f, (float) point.getY() + 4f);
                }
            }

            continue outer; // NOPMD -- Continue the outer loop, not the inner one
        }
    }
    return point;
}
 
源代码9 项目: consulo   文件: LineNumberConvertor.java
private static int convert(@Nonnull final TreeMap<Integer, Integer> fragments, int value) {
  Map.Entry<Integer, Integer> floor = fragments.floorEntry(value);
  if (floor == null || floor.getValue() == -1) return -1;
  return floor.getValue() - floor.getKey() + value;
}
 
源代码10 项目: systemsgenetics   文件: GenomicBoundaries.java
/**
 * This method returns a Boundary object from a chromosome at a specific position.
 * 
 * @param chromosome
 * @param position
 * @return 
 */
public GenomicBoundary getBoundary(String chromosome, int position, int listIndex){

	/*
	if(!removedSubBoundaries){
		throw new IllegalStateException("Can not get boundary is sub boundaries not removed.");
	}
	*/
	
       if(isChromosomeInBoundary(chromosome)){

		TreeMap<Integer, ArrayList<GenomicBoundary<V>>> chromosomeBoudaries = genomicsBoundaries.get(chromosome);
		//if(position >= (chromosomeBoudaries.firstKey() - margin) && position <= (chromosomeBoudaries.lastKey() + margin)){
		Entry<Integer, ArrayList<GenomicBoundary<V>>> boundaryEntry = chromosomeBoudaries.floorEntry(position + margin);

		if(boundaryEntry != null){
			ArrayList<GenomicBoundary<V>> boundary = boundaryEntry.getValue();
			if (boundary.get(listIndex).isInBoundarie(position,margin)){
				return boundary.get(listIndex);
			}
		}
		

		

       }

       return null;

   }