Code example for SortedMap

Methods: comparator

0
SortedMap sortedMap = new PresortedMap(comparator != null && JVM.hasOptimizedTreeMapPutAll() ? comparator
				: null); 
		if (inFirstElement) {
			// we are already within the first entry 
			putCurrentEntryIntoMap(reader, context, result, sortedMap);
			reader.moveUp();
		} 
		populateMap(reader, context, result, sortedMap);
		try { 
			if (JVM.hasOptimizedTreeMapPutAll()) { 
				if (comparator != null && comparatorField != null) {
					comparatorField.set(result, comparator);
				} 
				result.putAll(sortedMap); // internal optimization will not call comparator
			} else if (comparatorField != null) {
				comparatorField.set(result, sortedMap.comparator());
				result.putAll(sortedMap); // "sort" by index
				comparatorField.set(result, comparator);
			} else { 
				result.putAll(sortedMap); // will use comparator for already sorted map
			}