org.apache.commons.collections4.bidimap.TreeBidiMap Java Examples
The following examples show how to use
org.apache.commons.collections4.bidimap.TreeBidiMap.
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: Collections4.java From Learn-Java-12-Programming with MIT License | 5 votes |
private static void bidiMap(){ System.out.println("\nbidiMap():"); BidiMap<Integer, String> bidi = new TreeBidiMap<>(); bidi.put(2, "two"); bidi.put(3, "three"); System.out.println(bidi); //prints: {2=two, 3=three} System.out.println(bidi.inverseBidiMap()); //prints: {three=3, two=2} System.out.println(bidi.get(3)); //prints: three System.out.println(bidi.getKey("three")); //prints: 3 bidi.removeValue("three"); System.out.println(bidi); //prints: {2=two} }
Example #2
Source File: Section.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Retrieves the length of the given property (by key) * * @param offset2Id the offset to id map * @param entryOffset the current entry key * @param maxSize the maximum offset/size of the section stream * @return the length of the current property */ private static int propLen( TreeBidiMap<Long,Long> offset2Id, Long entryOffset, long maxSize) { Long nextKey = offset2Id.nextKey(entryOffset); long begin = entryOffset; long end = (nextKey != null) ? nextKey : maxSize; return (int)(end - begin); }