srakaselection.blogg.se

Sorted3 api
Sorted3 api









Parameters: toKey - high endpoint (exclusive) of the keys in the returned map Returns: a view of the portion of this map whose keys are strictly On an attempt to insert a key outside its range. Optional map operations that this map supports. The returned map is backedīy this map, so changes in the returned map are reflected in Returns a view of the portion of this map whose keys are ToKey or if this map itself has a restricted

sorted3 api

Is null and this map does not permit null keys IllegalArgumentException - if fromKey is greater than NullPointerException - if fromKey or toKey Implementations may, but are not required to, throw thisĬannot be compared to keys currently in the map. (or, if the map has no comparator, using natural ordering). Parameters: fromKey - low endpoint (inclusive) of the keys in the returned map toKey - high endpoint (exclusive) of the keys in the returned map Returns: a view of the portion of this map whose keys range fromįromKey, inclusive, to toKey, exclusive Throws: ClassCastException - if fromKey and toKeyĬannot be compared to one another using this map's comparator The returned map will throw an IllegalArgumentException

sorted3 api

The returned map supports all optional map operations that this In the returned map are reflected in this map, and vice-versa. Is empty.) The returned map is backed by this map, so changes (IfįromKey and toKey are equal, the returned map Returns a view of the portion of this map whose keys range fromįromKey, inclusive, to toKey, exclusive. SortedMap sub = m.subMap(low+"\0", high) View containing all of the key-value mappings in m whose keys SortedMap sub = m.subMap(low, high+"\0") Ī similar technique can be used to generate an open range The following idiom obtains a viewĬontaining all of the key-value mappings in m whose keys are If you need aĬlosed range (which includes both endpoints), and the key typeĪllows for calculation of the successor of a given key, merely request Such ranges are half-open, that is, they include their lowĮndpoint but not their high endpoint (where applicable). Note: several methods return submaps with restricted key

  • A constructor with a single argument of type SortedMap, whichĬreates a new sorted map with the same key-value mappings and the same.
  • A constructor with a single argument of type Map, which createsĪ new map with the same key-value mappings as its argument, sorted.
  • A constructor with a single argument of type Comparator, whichĬreates an empty sorted map sorted according to the specified comparator.
  • Sorted according to the natural ordering of its keys.
  • A void (no arguments) constructor, which creates an empty sorted map.
  • TheĮxpected "standard" constructors for all sorted map implementations are: Though as required constructors cannot be specified by interfaces. It is not possible to enforce this recommendation Ordering is inconsistent with equals it just fails to obey the generalĪll general-purpose sorted map implementation classes should provide four The behavior of a tree map is well-defined even if its Operation, but a sorted map performs all key comparisons using itsĬompareTo (or compare) method, so two keys that areĭeemed equal by this method are, from the standpoint of the sorted map,Įqual. The Map interface is defined in terms of the equals Precise definition of consistent with equals.) This is so because The Comparable interface or Comparator interface for a The sorted map is to correctly implement the Map interface. Note that the ordering maintained by a sorted map (whether or not anĮxplicit comparator is provided) must be consistent with equals if Offending method or constructor invocation to throw a Attempts to violate this restriction will cause the Such keys must be mutually comparable: k1.compareTo(k2) (orĬpare(k1, k2)) must not throw aĬlassCastException for any keys k1 and k2 in Interface (or be accepted by the specified comparator).

    sorted3 api

    (This interface is the map analogue of SortedSet.)Īll keys inserted into a sorted map must implement the Comparable Several additional operations are provided to take advantage of the Iterating over the sorted map's collection views (returned by the Ordering of its keys, or by a Comparator typically The map is ordered according to the natural A Map that further provides a total ordering on its keys.











    Sorted3 api