/** * Factory method to create an unmodifiable sorted map. * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map) { if (map is Unmodifiable) { return(map); } return(new UnmodifiableSortedMap(map)); }
/** * Constructor. * @param bidi the parent bidi map * @param sm the subMap sorted map */ protected internal ViewMap(DualTreeBidiMap bidi, java.util.SortedMap <Object, Object> sm) : // the implementation is not great here... // use the maps[0] as the filtered map, but maps[1] as the full map // this forces containsValue and clear to be overridden base((java.util.SortedMap <Object, Object>)bidi.createBidiMap(sm, bidi.maps[1], bidi.inverseBidiMapJ)) { this.bidi = (DualTreeBidiMap)map; }
/** * Factory method to create a typed sorted map. * <p> * If there are any elements already in the map being decorated, they * are validated. * * @param map the map to decorate, must not be null * @param keyType the type to allow as keys, must not be null * @param valueType the type to allow as values, must not be null * @throws IllegalArgumentException if list or type is null * @throws IllegalArgumentException if the list contains invalid elements */ public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, java.lang.Class keyType, java.lang.Class valueType) { return(new PredicatedSortedMap( map, InstanceofPredicate.getInstance(keyType), InstanceofPredicate.getInstance(valueType) )); }
/** * Factory method to create a transforming sorted map that will transform * existing contents of the specified map. * <p> * If there are any elements already in the map being decorated, they * will be transformed by this method. * Constrast this with {@link #decorate}. * * @param map the map to decorate, must not be null * @param keyTransformer the transformer to use for key conversion, null means no transformation * @param valueTransformer the transformer to use for value conversion, null means no transformation * @throws IllegalArgumentException if map is null * @since Commons Collections 3.2 */ public static java.util.SortedMap <Object, Object> decorateTransform(java.util.SortedMap <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer) { TransformedSortedMap decorated = new TransformedSortedMap(map, keyTransformer, valueTransformer); if (map.size() > 0) { java.util.Map <Object, Object> transformed = decorated.transformMap(map); decorated.clear(); decorated.getMap().putAll(transformed); // avoids double transformation } return(decorated); }
public virtual Object previousKey(Object key) { if (isEmpty()) { return(null); } if (maps[0] is OrderedMap) { return(((OrderedMap)maps[0]).previousKey(key)); } java.util.SortedMap <Object, Object> sm = (java.util.SortedMap <Object, Object>)maps[0]; java.util.SortedMap <Object, Object> hm = sm.headMap(key); if (hm.isEmpty()) { return(null); } return(hm.lastKey()); }
public virtual Object nextKey(Object key) { if (isEmpty()) { return(null); } if (maps[0] is OrderedMap) { return(((OrderedMap)maps[0]).nextKey(key)); } java.util.SortedMap <Object, Object> sm = (java.util.SortedMap <Object, Object>)maps[0]; java.util.Iterator <Object> it = sm.tailMap(key).keySet().iterator(); it.next(); if (it.hasNext()) { return(it.next()); } return(null); }
/** * Construct a new map with the same mappings as the specified map, * sorted according to the same ordering * * @param map the map whose mappings are to be copied */ public FastTreeMap(java.util.SortedMap <Object, Object> map) : base() { this.map = new java.util.TreeMap <Object, Object>(map); }
/** * Factory method to create a predicated (validating) sorted map. * <p> * If there are any elements already in the list being decorated, they * are validated. * * @param map the map to decorate, must not be null * @param keyPredicate the predicate to validate the keys, null means no check * @param valuePredicate the predicate to validate to values, null means no check * @throws IllegalArgumentException if the map is null */ public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, Predicate keyPredicate, Predicate valuePredicate) { return(new PredicatedSortedMap(map, keyPredicate, valuePredicate)); }
//----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @param keyPredicate the predicate to validate the keys, null means no check * @param valuePredicate the predicate to validate to values, null means no check * @throws IllegalArgumentException if the map is null */ protected internal PredicatedSortedMap(java.util.SortedMap <Object, Object> map, Predicate keyPredicate, Predicate valuePredicate) : base(map, keyPredicate, valuePredicate) { }
public java.util.SortedMap <Object, Object> headMap(Object toKey) { java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey); return(new PredicatedSortedMap(map, keyPredicate, valuePredicate)); }
public java.util.SortedMap <Object, Object> tailMap(Object fromKey) { java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey); return(new PredicatedSortedMap(map, keyPredicate, valuePredicate)); }
public override java.util.SortedMap <Object, Object> tailMap(Object fromKey) { java.util.SortedMap <Object, Object> sm = getSortedBidiMap().tailMap(fromKey); return(UnmodifiableSortedMap.decorate(sm)); }
//----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ protected FixedSizeSortedMap(java.util.SortedMap <Object, Object> map) : base(map) { }
public java.util.SortedMap <Object, Object> headMap(Object toKey) { java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey); return(new LazySortedMap(map, factory)); }
/** * Factory method to create a lazily instantiated sorted map. * * @param map the map to decorate, must not be null * @param factory the factory to use, must not be null * @throws IllegalArgumentException if map or factory is null */ public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, Transformer factory) { return(new LazySortedMap(map, factory)); }
public override java.util.SortedMap <Object, Object> subMap(Object fromKey, Object toKey) { java.util.SortedMap <Object, Object> map = getSortedMap().subMap(fromKey, toKey); return(new UnmodifiableSortedMap(map)); }
/** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if the collection is null */ public AbstractSortedMapDecorator(java.util.SortedMap <Object, Object> map) : base(map) { }
//----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ private UnmodifiableSortedMap(java.util.SortedMap <Object, Object> map) : base(map) { }
/** * Factory method to create a transforming sorted map. * <p> * If there are any elements already in the map being decorated, they * are NOT transformed. * Constrast this with {@link #decorateTransform}. * * @param map the map to decorate, must not be null * @param keyTransformer the predicate to validate the keys, null means no transformation * @param valueTransformer the predicate to validate to values, null means no transformation * @throws IllegalArgumentException if the map is null */ public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer) { return(new TransformedSortedMap(map, keyTransformer, valueTransformer)); }
public java.util.SortedMap <Object, Object> tailMap(Object fromKey) { java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey); return(new TransformedSortedMap(map, keyTransformer, valueTransformer)); }
public java.util.SortedMap <Object, Object> headMap(Object toKey) { java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey); return(new TransformedSortedMap(map, keyTransformer, valueTransformer)); }
//----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * <p> * If there are any elements already in the collection being decorated, they * are NOT transformed.</p> * * @param map the map to decorate, must not be null * @param keyTransformer the predicate to validate the keys, null means no transformation * @param valueTransformer the predicate to validate to values, null means no transformation * @throws IllegalArgumentException if the map is null */ protected TransformedSortedMap(java.util.SortedMap <Object, Object> map, Transformer keyTransformer, Transformer valueTransformer) : base(map, keyTransformer, valueTransformer) { }
public virtual java.util.SortedMap <Object, Object> subMap(Object fromKey, Object toKey) { java.util.SortedMap <Object, Object> sub = ((java.util.SortedMap <Object, Object>)maps[0]).subMap(fromKey, toKey); return(new ViewMap(this, sub)); }
public override java.util.SortedMap <Object, Object> headMap(Object toKey) { java.util.SortedMap <Object, Object> map = getSortedMap().headMap(toKey); return(new FixedSizeSortedMap(map)); }
/** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @param factory the factory to use, must not be null * @throws IllegalArgumentException if map or factory is null */ protected LazySortedMap(java.util.SortedMap <Object, Object> map, Transformer factory) : base(map, factory) { }
public override java.util.SortedMap <Object, Object> tailMap(Object fromKey) { java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey); return(new FixedSizeSortedMap(map)); }
public java.util.SortedMap <Object, Object> tailMap(Object fromKey) { java.util.SortedMap <Object, Object> map = getSortedMap().tailMap(fromKey); return(new LazySortedMap(map, factory)); }
/** * Factory method to create a fixed size sorted map. * * @param map the map to decorate, must not be null * @throws IllegalArgumentException if map is null */ public static java.util.SortedMap <Object, Object> decorate(java.util.SortedMap <Object, Object> map) { return(new FixedSizeSortedMap(map)); }
//----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @param factory the factory to use, must not be null * @throws IllegalArgumentException if map or factory is null */ protected LazySortedMap(java.util.SortedMap <Object, Object> map, Factory factory) : base(map, factory) { }
public override java.util.SortedMap <Object, Object> headMap(Object toKey) { java.util.SortedMap <Object, Object> sm = getSortedBidiMap().headMap(toKey); return(UnmodifiableSortedMap.decorate(sm)); }