Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. @Override
  2. public float get(long timestamp) {
  3. if (cachedHigherTs != -1) {
  4. if (timestamp < cachedHigherTs) {
  5. return cachedVal;
  6. }
  7. }
  8. Entry<Long, Float> result = samples.floorEntry(timestamp);
  9. Entry<Long, Float> higher = samples.higherEntry(timestamp);
  10.  
  11. if (result == null) {
  12. cachedVal = 0.0f;
  13. } else {
  14. cachedVal = result.getValue();
  15. }
  16.  
  17. if (higher == null) {
  18. cachedHigherTs = Long.MAX_VALUE;
  19. } else {
  20. cachedHigherTs = higher.getKey();
  21. }
  22. return cachedVal;
  23. }
  24.  
  25.  
  26.  
  27. ==========
  28. @Override
  29. public float get(long timestamp) {
  30. return getFloor(timestamp);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement