+
+ return new Ordered<>(offsets, array);
+ }
+
+ /**
+ * Create an {@link ImmutableOffsetMap} as a copy of an existing map. This is actually not completely true, as this
+ * method returns an {@link ImmutableMap} for empty and singleton inputs, as those are more memory-efficient. This
+ * method also recognizes {@link ImmutableOffsetMap} and {@link SharedSingletonMap} on input, and returns it back
+ * without doing anything else. It also recognizes {@link MutableOffsetMap} (as returned by
+ * {@link #toModifiableMap()}) and makes an efficient copy of its contents. All other maps are converted to an
+ * {@link ImmutableOffsetMap}. Iterator order is not guaranteed to be retained.
+ *
+ * @param map Input map, may not be null.
+ * @return An isolated, immutable copy of the input map
+ * @throws NullPointerException if {@code map} or any of its elements is null.
+ */
+ public static <K, V> @NonNull Map<K, V> unorderedCopyOf(final @NonNull Map<K, V> map) {
+ final Map<K, V> common = commonCopy(map);
+ if (common != null) {
+ return common;
+ }
+
+ final int size = map.size();