All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.qt.core.QMultiMap Maven / Gradle / Ivy

/****************************************************************************
**
** Copyright (C) 2009-2024 Dr. Peter Droste, Omix Visualization GmbH & Co. KG. All rights reserved.
**
** This file is part of Qt Jambi.
**
** $BEGIN_LICENSE$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
** 
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
** $END_LICENSE$

**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
package io.qt.core;

import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;

import io.qt.NativeAccess;
import io.qt.NonNull;
import io.qt.Nullable;
import io.qt.QNoImplementationException;
import io.qt.QNoNativeResourcesException;
import io.qt.QtUninvokable;
import io.qt.StrictNonNull;

/**
 * 

Java wrapper for Qt class QMultiMap

*/ public class QMultiMap extends AbstractMultiAssociativeContainer implements NavigableMap>, Cloneable { static { QtJambi_LibraryUtilities.initialize(); } /** * Constructor for internal use only. * @param p expected to be null. * @hidden */ @NativeAccess protected QMultiMap(QPrivateConstructor p) { super(p); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyType the type K * @param valueMetaType the type V */ public QMultiMap(Class keyType, QMetaType.Type valueMetaType) { this(keyType, new QMetaType(valueMetaType)); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyMetaType the type K * @param valueType the type V */ public QMultiMap(QMetaType.Type keyMetaType, Class valueType) { this(new QMetaType(keyMetaType), valueType); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyMetaType the type K * @param valueMetaType the type V */ public QMultiMap(QMetaType.Type keyMetaType, QMetaType valueMetaType) { this(new QMetaType(keyMetaType), valueMetaType); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyMetaType the type K * @param valueMetaType the type V */ public QMultiMap(QMetaType keyMetaType, QMetaType.Type valueMetaType) { this(keyMetaType, new QMetaType(valueMetaType)); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyMetaType the type K * @param valueMetaType the type V */ public QMultiMap(QMetaType.Type keyMetaType, QMetaType.Type valueMetaType) { this(new QMetaType(keyMetaType), new QMetaType(valueMetaType)); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyType the type K * @param valueType the type V */ public QMultiMap(Class keyType, Class valueType) { super(null); QMetaType keyMetaType = QMetaType.fromType(keyType); QMetaType valueMetaType = QMetaType.fromType(valueType); initialize(keyType, QtJambi_LibraryUtilities.internal.nativeId(keyMetaType), valueType, QtJambi_LibraryUtilities.internal.nativeId(valueMetaType), null); } /** * Creating a container with given content. *

See QMultiMap::QMultiMap(const QMap<Key, T> &)

* @param other map */ public QMultiMap(Map> other) { super(null); QPair metaTypes = findMapMetaType(Objects.requireNonNull(other, "Argument 'other': null not expected.")); initialize(metaTypes.first.javaType(), QtJambi_LibraryUtilities.internal.nativeId(metaTypes.first), metaTypes.second.javaType(), QtJambi_LibraryUtilities.internal.nativeId(metaTypes.second), other); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyType the type K * @param valueMetaType the type V */ public QMultiMap(Class keyType, QMetaType valueMetaType) { super(null); QMetaType keyMetaType = QMetaType.fromType(keyType); initialize(keyType, QtJambi_LibraryUtilities.internal.nativeId(keyMetaType), valueMetaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(valueMetaType), null); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyMetaType the type K * @param valueType the type V */ public QMultiMap(QMetaType keyMetaType, Class valueType) { super(null); QMetaType valueMetaType = QMetaType.fromType(valueType); initialize(keyMetaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(keyMetaType), valueMetaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(valueMetaType), null); } /** * Creating a container with given key and value type. *

See QMultiMap::QMultiMap()

* @param keyMetaType the type K * @param valueMetaType the type V */ public QMultiMap(QMetaType keyMetaType, QMetaType valueMetaType) { super(null); initialize(keyMetaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(keyMetaType), valueMetaType.javaType(), QtJambi_LibraryUtilities.internal.nativeId(valueMetaType), null); } @QtUninvokable private native void initialize(Class keyType, long keyMetaType, Class valueType, long valueMetaType, Map> other); /** * Creates and returns a copy of this object. *

See QMultiMap::QMultiMap(const QMultiMap<Key, T> &)

*/ @Override public QMultiMap clone(){ return new QMultiMap<>(this); } /** *

See QMultiMap::clear()

*/ @QtUninvokable public final void clear() { clear(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native void clear(long __this__nativeId); /** *

See QMultiMap::contains(Key)const

*/ @QtUninvokable public final boolean contains(Key key) { try{ return contains(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, keyMetaType(), key); } } @QtUninvokable private native boolean contains(long __this__nativeId, Object key); /** *

See QMultiMap::count()const

*/ @QtUninvokable public final int count() { return size(); } /** *

See QMultiMap::count(Key)const

*/ @QtUninvokable public final int count(Key key) { try{ return count(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, keyMetaType(), key); } } @QtUninvokable private native int count(long __this__nativeId, Key key); /** * Provides a mutable C++ iterator to the containers begin. *

See QMultiMap::begin()

* @return begin */ @QtUninvokable protected final io.qt.core.QAssociativeIterator begin() { return begin(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native io.qt.core.QAssociativeIterator begin(long __this__nativeId); /** * Provides a mutable C++ iterator to the containers end. *

See QMultiMap::end()

* @return end */ @QtUninvokable protected final io.qt.core.QAssociativeIterator end() { return end(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native io.qt.core.QAssociativeIterator end(long __this__nativeId); /** * Provides a constant C++ iterator to the containers begin. *

See QMultiMap::constBegin()const

* @return begin */ @QtUninvokable protected final io.qt.core.QAssociativeConstIterator constBegin() { return constBegin(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native io.qt.core.QAssociativeConstIterator constBegin(long __this__nativeId); /** * Provides a constant C++ iterator to the containers end. *

See QMultiMap::constEnd()const

* @return end */ @QtUninvokable protected final io.qt.core.QAssociativeConstIterator constEnd() { return constEnd(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native io.qt.core.QAssociativeConstIterator constEnd(long __this__nativeId); /** *

See QMultiMap::find(Key)const

* @return iterator */ @QtUninvokable public final io.qt.core.QAssociativeConstIterator find(Key key) { try{ return find(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, keyMetaType(), key); } } @QtUninvokable private native io.qt.core.QAssociativeConstIterator find(long __this__nativeId, Key key); /** *

See QMultiMap::first()const

*/ @QtUninvokable public final T first() { return first(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native T first(long __this__nativeId); /** *

See QMultiMap::firstKey()const

*/ @QtUninvokable public final Key firstKey() { return firstKey(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native Key firstKey(long __this__nativeId); /** *

See QMultiMap::insert(Key,T)

*/ @QtUninvokable public final void insert(Key key, T value) { try{ insert(QtJambi_LibraryUtilities.internal.nativeId(this), key, value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, value); } } @QtUninvokable private native void insert(long __this__nativeId, Key key, T value); /** *

See QMultiMap::isEmpty()const

*/ @QtUninvokable public final boolean isEmpty() { return size()==0; } /** *

See QMultiMap::key(T)const

*/ @QtUninvokable public final Key key(T value) { return key(value, null); } /** *

See QMultiMap::key(T,Key)const

*/ @QtUninvokable public final Key key(T value, Key defaultKey) { try{ return key(QtJambi_LibraryUtilities.internal.nativeId(this), value, defaultKey); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, valueMetaType(), value); } } @QtUninvokable private native Key key(long __this__nativeId, T value, Key defaultKey); /** * Returns a {@link List} of the keys contained in this associative container. *

See QMultiMap::keys()const

* @return list of keys */ @QtUninvokable public final QList keys() { return keys(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native QList keys(long __this__nativeId); /** *

See QMultiMap::keys(T)const

*/ @QtUninvokable public final QList keys(T value) { try{ return keysForValue(QtJambi_LibraryUtilities.internal.nativeId(this), value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, valueMetaType(), value); } } @QtUninvokable private native QList keysForValue(long __this__nativeId, Object value); /** *

See QMultiMap::last()const

*/ @QtUninvokable public final T last() { return last(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native T last(long __this__nativeId); /** *

See QMultiMap::lastKey()const

*/ @QtUninvokable public final Key lastKey() { return lastKey(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native Key lastKey(long __this__nativeId); /** *

See QMultiMap::lowerBound(Key)const

*/ @QtUninvokable public final io.qt.core.QAssociativeConstIterator lowerBound(Key key) { try{ return lowerBound(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, keyMetaType(), key); } } @QtUninvokable private native io.qt.core.QAssociativeConstIterator lowerBound(long __this__nativeId, Key key); /** *

See QMultiMap::removeIf(Predicate)

*/ @QtUninvokable public final int removeIf(Predicate predicate) { List keys = new ArrayList<>(); final long nativeId = QtJambi_LibraryUtilities.internal.nativeId(this); for(Key key : keys(nativeId)) { if(predicate.test(key)) keys.add(key); } int count = 0; for (Key key : keys) { count += remove(nativeId, key); } return count; } /** *

See QMultiMap::removeIf(Predicate)

*/ @QtUninvokable public final int removeIf(BiPredicate predicate) { List> pairs = new ArrayList<>(); final long nativeId = QtJambi_LibraryUtilities.internal.nativeId(this); for(QPair pair : constBegin(nativeId)) { if(predicate.test(pair.first, pair.second)) pairs.add(pair); } int count = 0; for (QPair pair : pairs) { count += remove(nativeId, pair.first, pair.second); } return count; } /** *

See QMultiMap::remove(Key)

*/ @QtUninvokable public final int removeAll(Object key) { try{ return remove(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return 0; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, keyMetaType(), key); if(e1==e) throw e; return 0; } } @QtUninvokable private native int remove(long __this__nativeId, Object key); /** *

See QMultiMap::size()const

*/ @QtUninvokable public final int size() { return size(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native int size(long __this__nativeId); /** *

See QMultiMap::take(Key)

*/ @QtUninvokable public final T take(Key key) { try { return take(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, keyMetaType(), key); } } @QtUninvokable private native T take(long __this__nativeId, Key key); /** *

See QMultiMap::uniqueKeys()const

*/ @QtUninvokable public final QList uniqueKeys() { return uniqueKeys(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private static native QList uniqueKeys(long __this__nativeId); /** *

See QMultiMap::unite(const QMap<Key, T> &)const

*/ @QtUninvokable public final void unite(QMap other) { unite(QtJambi_LibraryUtilities.internal.nativeId(this), other); } /** *

See QMultiMap::unite(const QMultiMap<Key, T> &)const

*/ @QtUninvokable public final void unite(java.util.Map> other) { unite(QtJambi_LibraryUtilities.internal.nativeId(this), other); } @QtUninvokable private static native void unite(long __this__nativeId, Object other); /** *

See QMultiMap::upperBound(Key)const

*/ @QtUninvokable public final io.qt.core.QAssociativeConstIterator upperBound(Key key) { return upperBound(QtJambi_LibraryUtilities.internal.nativeId(this), key); } @QtUninvokable private native io.qt.core.QAssociativeConstIterator upperBound(long __this__nativeId, Key key); /** *

See QMultiMap::value(Key)const

*/ @QtUninvokable public final T value(Key key) { return value(key, null); } /** *

See QMultiMap::value(Key,T)const

*/ @QtUninvokable public final T value(Key key, T defaultValue) { try{ return value(QtJambi_LibraryUtilities.internal.nativeId(this), key, defaultValue); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, defaultValue); } } @QtUninvokable private native T value(long __this__nativeId, Object key, Object defaultValue); /** * Returns a {@link List} of the values contained in this multimap. * @see Map#values() */ @Override @QtUninvokable public final java.util.List> values() { long id = QtJambi_LibraryUtilities.internal.nativeId(this); java.util.List> result = new java.util.ArrayList<>(); for(Object key : uniqueKeys(id)) { result.add(valuesKey(id, key)); } return result; } /** *

See QMultiMap::values()const

*/ @QtUninvokable public final QList listOfValues() { return values(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native QList values(long __this__nativeId); /** *

See QMultiMap::values(Key)const

*/ @QtUninvokable public final QList values(Key key) { try{ return valuesKey(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QSet.handleException(e, keyMetaType(), key); } } @QtUninvokable private static native QList valuesKey(long __this__nativeId, Key key); /** *

See QMultiMap::contains(Key,T)const

*/ @QtUninvokable public final boolean contains(Key key, T value) { try{ return contains(QtJambi_LibraryUtilities.internal.nativeId(this), key, value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, value); } } @QtUninvokable private static native boolean contains(long __this__nativeId, Key key, T value); /** *

See QMultiMap::count(Key,T)const

*/ @QtUninvokable public final int count(Key key, T value) { try{ return count(QtJambi_LibraryUtilities.internal.nativeId(this), key, value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, value); } } @QtUninvokable private static native int count(long __this__nativeId, Key key, T value); /** *

See QMultiMap::find(Key,T)const

*/ @QtUninvokable public final io.qt.core.QAssociativeConstIterator find(Key key, T value) { try{ return find(QtJambi_LibraryUtilities.internal.nativeId(this), key, value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, value); } } @QtUninvokable private static native io.qt.core.QAssociativeConstIterator find(long __this__nativeId, Key key, T value); /** *

See QMultiMap::remove(Key,T)

*/ @QtUninvokable public final int removeAll(Key key, T value) { try{ return remove(QtJambi_LibraryUtilities.internal.nativeId(this), key, value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, value); } } @QtUninvokable private static native int remove(long __this__nativeId, Key key, T value); /** *

See QMultiMap::replace(Key,T)

*/ @QtUninvokable public final void replaceOne(Key key, T value) { try{ replace(QtJambi_LibraryUtilities.internal.nativeId(this), key, value); }catch(QNoNativeResourcesException e) { throw e; }catch(RuntimeException e) { throw QMap.handleException(e, keyMetaType(), valueMetaType(), key, value); } } @QtUninvokable private static native void replace(long __this__nativeId, Key key, T value); /** *

See operator==(QMultiMap<Key,T>,QMultiMap<Key,T>)

*/ @SuppressWarnings("unchecked") @Override @QtUninvokable public boolean equals(Object other) { if (other instanceof java.util.Map && QMap.checkContainerType(this.keyMetaType(), this.valueMetaType(), (java.util.Map) other)) { return operator_equal(QtJambi_LibraryUtilities.internal.nativeId(this), (java.util.Map) other); } return false; } @QtUninvokable private native boolean operator_equal(long __this__nativeId, java.util.Map other); /** * Returns the maps comparator. */ @Override @QtUninvokable public final java.util.Comparator comparator(){ return QMap.createComparator(keyMetaType().javaType(), this); } /** * Returns {@code true} if this map contains a mapping for the specified key. * @see Map#containsKey(Object) * @see #contains(Object) */ @Override @QtUninvokable public final boolean containsKey(Object key){ try{ return contains(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return false; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, keyMetaType(), key); if(e1==e) throw e; return false; } } /** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * @see Map#get(Object) * @see #value(Object) */ @Override @QtUninvokable public final List get(Object key){ try{ return valuesKey(QtJambi_LibraryUtilities.internal.nativeId(this), key); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return null; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, keyMetaType(), key); if(e1==e) throw e; return null; } } /** * Associates the specified value with the specified key in this map. * @see Map#put(Object, Object) * @see #insert(Object, Object) */ @Override @QtUninvokable public final java.util.List put(Key key, java.util.List values){ QList old = values(key); for(T value : values) insert(key, value); return old; } /** * Removes the mapping for a key from this map if it is present. * @see Map#remove(Object) * @see #take(Object) */ @SuppressWarnings("unchecked") @Override @QtUninvokable public final java.util.List remove(Object key){ try{ QList result = valuesKey(QtJambi_LibraryUtilities.internal.nativeId(this), (Key)key); removeAll(key); return result; }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return Collections.emptyList(); }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, keyMetaType(), key); if(e1==e) throw e; return Collections.emptyList(); } } /** * Returns {@code true} if this map maps one or more keys to the * specified value. * @see Map#containsValue(Object) * @see #key(Object, Object) */ @Override @QtUninvokable public final boolean containsValue(Object value){ try { return !keysForValue(QtJambi_LibraryUtilities.internal.nativeId(this), value).isEmpty(); }catch(QNoNativeResourcesException e) { throw e; }catch(IllegalArgumentException e) { return false; }catch(RuntimeException e) { RuntimeException e1 = QSet.handleException(e, valueMetaType(), value); if(e1==e) throw e; return false; } } /** * Returns the objects's hash code computed by qHash(QMultiMap<Key,T>). */ @Override @QtUninvokable public int hashCode() { try { return hashCode(QtJambi_LibraryUtilities.internal.nativeId(this)); } catch (QNoNativeResourcesException e) { return 0; } } @QtUninvokable private static native int hashCode(long __this__nativeId); /** * Returns the string representation of the object given by QVariant(this).toString(). */ @Override @QtUninvokable public String toString() { try { return toString(QtJambi_LibraryUtilities.internal.nativeId(this)); } catch (QNoImplementationException e) { return super.toString(); } catch (QNoNativeResourcesException e) { return "null"; } } @QtUninvokable private static native String toString(long __this__nativeId); /** *

See operator<<(QDataStream&,QMultiMap<Key,T>)

*/ @io.qt.QtUninvokable public void writeTo(io.qt.core.QDataStream stream){ writeTo(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.nativeId(stream)); } @io.qt.QtUninvokable private native void writeTo(long __this__nativeId, long stream); /** *

See operator>>(QDataStream&,QMultiMap<Key,T>&)

*/ @io.qt.QtUninvokable public void readFrom(io.qt.core.QDataStream stream){ readFrom(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.nativeId(stream)); } @io.qt.QtUninvokable private native void readFrom(long __this__nativeId, long stream); @io.qt.QtUninvokable final QMetaType keyMetaType() { return keyMetaType(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native QMetaType keyMetaType(long __this_nativeId); @io.qt.QtUninvokable final QMetaType valueMetaType() { return valueMetaType(QtJambi_LibraryUtilities.internal.nativeId(this)); } @io.qt.QtUninvokable private native QMetaType valueMetaType(long __this_nativeId); /** * Returns a QMultiMap containing a single mapping. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the mapping's key * @param t1 the mapping's value * @return a {@code QMultiMap} containing the specified mapping * @throws NullPointerException if the key or the value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1), QList.findElementMetaType(t1)); result.insert(k1, t1); return result; } /** * Returns a QMultiMap containing two mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2), QList.findElementMetaType(t1, t2)); result.insert(k1, t1); result.insert(k2, t2); return result; } /** * Returns a QMultiMap containing three mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3), QList.findElementMetaType(t1, t2, t3)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); return result; } /** * Returns a QMultiMap containing four mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4), QList.findElementMetaType(t1, t2, t3, t4)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); return result; } /** * Returns a QMultiMap containing five mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4, k5), QList.findElementMetaType(t1, t2, t3, t4, t5)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); return result; } /** * Returns a QMultiMap containing six mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4, k5, k6), QList.findElementMetaType(t1, t2, t3, t4, t5, t6)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); return result; } /** * Returns a QMultiMap containing seven mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4, k5, k6, k7), QList.findElementMetaType(t1, t2, t3, t4, t5, t6, t7)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); return result; } /** * Returns a QMultiMap containing eight mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4, k5, k6, k7, k8), QList.findElementMetaType(t1, t2, t3, t4, t5, t6, t7, t8)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); result.insert(k8, t8); return result; } /** * Returns a QMultiMap containing nine mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @param k9 the ninth mapping's key * @param t9 the ninth mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8, Key k9, T t9) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4, k5, k6, k7, k8, k9), QList.findElementMetaType(t1, t2, t3, t4, t5, t6, t7, t8, t9)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); result.insert(k8, t8); result.insert(k9, t9); return result; } /** * Returns a QMultiMap containing ten mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @param k9 the ninth mapping's key * @param t9 the ninth mapping's value * @param k10 the tenth mapping's key * @param t10 the tenth mapping's value * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any key or value is {@code null} */ public static @NonNull QMultiMap of(Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8, Key k9, T t9, Key k10, T t10) { QMultiMap result = new QMultiMap<>( QList.findElementMetaType(k1, k2, k3, k4, k5, k6, k7, k8, k9, k10), QList.findElementMetaType(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10)); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); result.insert(k8, t8); result.insert(k9, t9); result.insert(k10, t10); return result; } /** * Returns a QMultiMap containing keys and values extracted from the given entries. * * @apiNote * It is convenient to create the map entries using the {@link Map#entry Map.entry()} method. * For example, * *
{@code
     *     import static java.util.Map.entry;
     *
     *     QMultiMap map = QMultiMap.ofEntries(
     *         entry(1, "a"),
     *         entry(2, "b"),
     *         entry(3, "c"),
     *         ...
     *         entry(26, "z"));
     * }
* * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param entries {@code java.util.Map.Entry}s containing the keys and values from which the map is populated * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any entry, key, or value is {@code null}, or if * the {@code entries} array is {@code null} */ @SafeVarargs public static @NonNull QMultiMap ofEntries(Map.@StrictNonNull Entry entry0, Map.@StrictNonNull Entry @StrictNonNull... entries) { QPair metaTypes = QMap.findMapMetaType(entry0, entries); QMultiMap result = new QMultiMap<>(metaTypes.first, metaTypes.second); result.insert(entry0.getKey(), entry0.getValue()); for (Map.Entry entry : entries) { result.insert(entry.getKey(), entry.getValue()); } return result; } private static QPair findMapMetaType(Map> elements){ if(elements.getClass()==QMap.class) { return new QPair<>(((QMap)elements).keyMetaType(), ((QMap)elements).valueMetaType()); }else if(elements.getClass()==QHash.class) { return new QPair<>(((QHash)elements).keyMetaType(), ((QHash)elements).valueMetaType()); }else if(elements.getClass()==QMultiMap.class) { return new QPair<>(((QMultiMap)elements).keyMetaType(), ((QMultiMap)elements).valueMetaType()); }else if(elements.getClass()==QMultiHash.class) { return new QPair<>(((QMultiHash)elements).keyMetaType(), ((QMultiHash)elements).valueMetaType()); }else { QMetaType keyMetaType = new QMetaType(); Class keyType = null; QMetaType valueMetaType = new QMetaType(); Class valueType = null; for(Entry> entry : elements.entrySet()) { Object key = entry.getKey(); if(keyMetaType!=null) { QMetaType _result = QList.getMetaType(key); if(!keyMetaType.isValid() || keyMetaType.id()==QMetaType.Type.Nullptr.value()) keyMetaType = _result; if(!_result.equals(keyMetaType)) { keyMetaType = null; } } if(key!=null) { if(keyType==null) { keyType = key.getClass(); }else { Class type2 = key.getClass(); if(type2!=keyType) { if(type2.isAssignableFrom(keyType)) { keyType = type2; }else if(!keyType.isAssignableFrom(type2)) { do{ keyType = keyType.getSuperclass(); }while(!keyType.isAssignableFrom(type2)); } } } } for(Object value : entry.getValue()) { if(valueMetaType!=null) { QMetaType _result = QList.getMetaType(value); if(!valueMetaType.isValid() || valueMetaType.id()==QMetaType.Type.Nullptr.value()) valueMetaType = _result; if(!_result.equals(valueMetaType)) { valueMetaType = null; } } if(value!=null) { if(valueType==null) { valueType = value.getClass(); }else { Class type2 = value.getClass(); if(type2!=valueType) { if(type2.isAssignableFrom(valueType)) { valueType = type2; }else if(!valueType.isAssignableFrom(type2)) { do{ valueType = valueType.getSuperclass(); }while(!valueType.isAssignableFrom(type2)); } } } } } } if(keyMetaType==null) keyMetaType = QMetaType.fromType(keyType); if(valueMetaType==null) valueMetaType = QMetaType.fromType(valueType); return new QPair<>(keyMetaType, valueMetaType); } } /** * Returns a QMultiMap containing a single mapping. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the mapping's key * @param t1 the mapping's value * @return a {@code QMultiMap} containing the specified mapping */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1) { return ofTyped( QList.findElementMetaType(keyType, k1), QList.findElementMetaType(valueType, t1), k1, t1); } /** * Returns a QMultiMap containing two mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2) { return ofTyped( QList.findElementMetaType(keyType, k1, k2), QList.findElementMetaType(valueType, t1, t2), k1, t1, k2, t2); } /** * Returns a QMultiMap containing three mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3), QList.findElementMetaType(valueType, t1, t2, t3), k1, t1, k2, t2, k3, t3); } /** * Returns a QMultiMap containing four mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4), QList.findElementMetaType(valueType, t1, t2, t3, t4), k1, t1, k2, t2, k3, t3, k4, t4); } /** * Returns a QMultiMap containing five mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4, k5), QList.findElementMetaType(valueType, t1, t2, t3, t4, t5), k1, t1, k2, t2, k3, t3, k4, t4, k5, t5); } /** * Returns a QMultiMap containing six mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4, k5, k6), QList.findElementMetaType(valueType, t1, t2, t3, t4, t5, t6), k1, t1, k2, t2, k3, t3, k4, t4, k5, t5, k6, t6); } /** * Returns a QMultiMap containing seven mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4, k5, k6, k7), QList.findElementMetaType(valueType, t1, t2, t3, t4, t5, t6, t7), k1, t1, k2, t2, k3, t3, k4, t4, k5, t5, k6, t6, k7, t7); } /** * Returns a QMultiMap containing eight mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4, k5, k6, k7, k8), QList.findElementMetaType(valueType, t1, t2, t3, t4, t5, t6, t7, t8), k1, t1, k2, t2, k3, t3, k4, t4, k5, t5, k6, t6, k7, t7, k8, t8); } /** * Returns a QMultiMap containing nine mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @param k9 the ninth mapping's key * @param t9 the ninth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8, Key k9, T t9) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4, k5, k6, k7, k8, k9), QList.findElementMetaType(valueType, t1, t2, t3, t4, t5, t6, t7, t8, t9), k1, t1, k2, t2, k3, t3, k4, t4, k5, t5, k6, t6, k7, t7, k8, t8, k9, t9); } /** * Returns a QMultiMap containing ten mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @param k9 the ninth mapping's key * @param t9 the ninth mapping's value * @param k10 the tenth mapping's key * @param t10 the tenth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@Nullable Class keyType, @Nullable Class valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8, Key k9, T t9, Key k10, T t10) { return ofTyped( QList.findElementMetaType(keyType, k1, k2, k3, k4, k5, k6, k7, k8, k9, k10), QList.findElementMetaType(valueType, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10), k1, t1, k2, t2, k3, t3, k4, t4, k5, t5, k6, t6, k7, t7, k8, t8, k9, t9, k10, t10); } /** * Returns a QMultiMap containing a single mapping. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the mapping's key * @param t1 the mapping's value * @return a {@code QMultiMap} containing the specified mapping */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1) { if(keyType.id()==0) throw new IllegalArgumentException("QMetaType::UnknownType cannot be key type of QMultiMap."); if(keyType.id()==QMetaType.Type.Void.value()) throw new IllegalArgumentException("void cannot be key type of QMultiMap."); if(valueType.id()==0) throw new IllegalArgumentException("QMetaType::UnknownType cannot be value type of QMultiMap."); if(valueType.id()==QMetaType.Type.Void.value()) throw new IllegalArgumentException("void cannot be value type of QMultiMap."); QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); return result; } /** * Returns a QMultiMap containing two mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); return result; } /** * Returns a QMultiMap containing three mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); return result; } /** * Returns a QMultiMap containing four mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); return result; } /** * Returns a QMultiMap containing five mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); return result; } /** * Returns a QMultiMap containing six mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); return result; } /** * Returns a QMultiMap containing seven mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); return result; } /** * Returns a QMultiMap containing eight mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); result.insert(k8, t8); return result; } /** * Returns a QMultiMap containing nine mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @param k9 the ninth mapping's key * @param t9 the ninth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8, Key k9, T t9) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); result.insert(k8, t8); result.insert(k9, t9); return result; } /** * Returns a QMultiMap containing ten mappings. * * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param k1 the first mapping's key * @param t1 the first mapping's value * @param k2 the second mapping's key * @param t2 the second mapping's value * @param k3 the third mapping's key * @param t3 the third mapping's value * @param k4 the fourth mapping's key * @param t4 the fourth mapping's value * @param k5 the fifth mapping's key * @param t5 the fifth mapping's value * @param k6 the sixth mapping's key * @param t6 the sixth mapping's value * @param k7 the seventh mapping's key * @param t7 the seventh mapping's value * @param k8 the eighth mapping's key * @param t8 the eighth mapping's value * @param k9 the ninth mapping's key * @param t9 the ninth mapping's value * @param k10 the tenth mapping's key * @param t10 the tenth mapping's value * @return a {@code QMultiMap} containing the specified mappings */ public static @NonNull QMultiMap ofTyped(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Key k1, T t1, Key k2, T t2, Key k3, T t3, Key k4, T t4, Key k5, T t5, Key k6, T t6, Key k7, T t7, Key k8, T t8, Key k9, T t9, Key k10, T t10) { QMultiMap result = new QMultiMap<>(keyType, valueType); result.insert(k1, t1); result.insert(k2, t2); result.insert(k3, t3); result.insert(k4, t4); result.insert(k5, t5); result.insert(k6, t6); result.insert(k7, t7); result.insert(k8, t8); result.insert(k9, t9); result.insert(k10, t10); return result; } /** * Returns a QMultiMap containing keys and values extracted from the given entries. * * @apiNote * It is convenient to create the map entries using the {@link Map#entry Map.entry()} method. * For example, * *
{@code
     *     import static java.util.Map.entry;
     *
     *     QMultiMap map = QMultiMap.ofTypedEntries(
     *         int.class,
     *         String.class,
     *         entry(1, "a"),
     *         entry(2, "b"),
     *         entry(3, "c"),
     *         ...
     *         entry(26, "z"));
     * }
* * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param entries {@code java.util.Map.Entry}s containing the keys and values from which the map is populated * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any entry, key, or value is {@code null}, or if * the {@code entries} array is {@code null} */ @SafeVarargs public static @NonNull QMultiMap ofTypedEntries(@Nullable Class keyType, @Nullable Class valueType, Map.Entry... entries) { QPair metaTypes = QMap.findMapMetaType(keyType, valueType, entries); return ofTypedEntries(metaTypes.first, metaTypes.second, entries); } /** * Returns a QMultiMap containing keys and values extracted from the given entries. * * @apiNote * It is convenient to create the map entries using the {@link Map#entry Map.entry()} method. * For example, * *
{@code
     *     import static java.util.Map.entry;
     *
     *     QMultiMap map = QMultiMap.ofTypedEntries(
     *         QMetaType.fromType(int.class),
     *         QMetaType.fromType(String.class),
     *         entry(1, "a"),
     *         entry(2, "b"),
     *         entry(3, "c"),
     *         ...
     *         entry(26, "z"));
     * }
* * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param keyType key type * @param valueType value type * @param entries {@code java.util.Map.Entry}s containing the keys and values from which the map is populated * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any entry, key, or value is {@code null}, or if * the {@code entries} array is {@code null} */ @SafeVarargs public static @NonNull QMultiMap ofTypedEntries(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, Map.Entry... entries) { QMultiMap result = new QMultiMap<>(keyType, valueType); for (Map.Entry entry : entries) { result.insert(entry.getKey(), entry.getValue()); } return result; } /** * Returns a QMultiMap containing keys and values extracted from the given pairs. * * @apiNote * It is convenient to create the pair using the {@link QPair#pair(Object, Object)} method. * For example, * *
{@code
     *     import static java.util.QPair.pair;
     *
     *     QMultiMap map = QMultiMap.ofPairs(
     *         pair(1, "a"),
     *         pair(2, "b"),
     *         pair(3, "c"),
     *         ...
     *         pair(26, "z"));
     * }
* * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param pairs {@code QPair}s containing the keys and values from which the map is populated * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any pair, key, or value is {@code null}, or if * the {@code pairs} array is {@code null} */ @SafeVarargs public static @NonNull QMultiMap ofPairs(@StrictNonNull QPair pair0, @StrictNonNull QPair @StrictNonNull... pairs) { QPair metaTypes = QMap.findMapMetaType(pair0, pairs); QMultiMap result = new QMultiMap<>(metaTypes.first, metaTypes.second); result.insert(pair0.first, pair0.second); for (QPair entry : pairs) { result.insert(entry.first, entry.second); } return result; } /** * Returns a QMultiMap containing keys and values extracted from the given pairs. * * @apiNote * It is convenient to create the pair using the {@link QPair#pair(Object, Object)} method. * For example, * *
{@code
     *     import static java.util.QPair.pair;
     *
     *     QMultiMap map = QMultiMap.ofTypedPairs(
     *         int.class,
     *         String.class,
     *         pair(1, "a"),
     *         pair(2, "b"),
     *         pair(3, "c"),
     *         ...
     *         pair(26, "z"));
     * }
* * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param pairs {@code QPair}s containing the keys and values from which the map is populated * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any pair, key, or value is {@code null}, or if * the {@code pairs} array is {@code null} */ @SafeVarargs public static @NonNull QMultiMap ofTypedPairs(@Nullable Class keyType, @Nullable Class valueType, QPair... pairs) { QPair metaTypes = QMap.findMapMetaType(keyType, valueType, pairs); return ofTypedPairs(metaTypes.first, metaTypes.second, pairs); } /** * Returns a QMultiMap containing keys and values extracted from the given pairs. * * @apiNote * It is convenient to create the pair using the {@link QPair#pair(Object, Object)} method. * For example, * *
{@code
     *     import static java.util.QPair.pair;
     *
     *     QMultiMap map = QMultiMap.ofTypedPairs(
     *         QMetaType.fromType(int.class),
     *         QMetaType.fromType(String.class),
     *         pair(1, "a"),
     *         pair(2, "b"),
     *         pair(3, "c"),
     *         ...
     *         pair(26, "z"));
     * }
* * @param the {@code QMultiMap}'s key type * @param the {@code QMultiMap}'s value type * @param pairs {@code QPair}s containing the keys and values from which the map is populated * @return a {@code QMultiMap} containing the specified mappings * @throws NullPointerException if any pair, key, or value is {@code null}, or if * the {@code pairs} array is {@code null} */ @SafeVarargs public static @NonNull QMultiMap ofTypedPairs(@StrictNonNull QMetaType keyType, @StrictNonNull QMetaType valueType, QPair... pairs) { QMultiMap result = new QMultiMap<>(keyType, valueType); for (QPair entry : pairs) { result.insert(entry.first, entry.second); } return result; } /** *

Equivalent to {@code subMap(fromKey, true, toKey, false)}. */ @Override @QtUninvokable public final QMultiMap subMap(Key fromKey, Key toKey) { return subMap(fromKey, true, toKey, false); } /** *

Equivalent to {@code headMap(toKey, false)}. */ @Override @QtUninvokable public final QMultiMap headMap(Key toKey) { return headMap(toKey, false); } /** *

Equivalent to {@code tailMap(fromKey, true)}. */ @Override @QtUninvokable public final QMultiMap tailMap(Key fromKey) { return tailMap(fromKey, true); } /** * Returns a key-value mapping associated with the greatest key * strictly less than the given key, or {@code null} if there is * no such key. * @see NavigableMap#lowerEntry(Object) */ @Override @QtUninvokable public final Entry> lowerEntry(Key key) { QAssociativeConstIterator iterator = find(key); if(iterator.isValid()) { if(iterator.equals(constBegin())) return null; if(!iterator.equals(constEnd())) iterator.decrement(); }else { iterator = lowerBound(key); if(!iterator.isValid()) return null; } List values = new ArrayList<>(); Key _key = iterator.checkedKey(); Comparator comparator = comparator(); for(; comparator.compare(_key, iterator.checkedKey())==0 && !iterator.equals(constEnd()); iterator.increment()) { values.add(iterator.checkedValue()); } return new AbstractMap.SimpleImmutableEntry<>(iterator.checkedKey(), values); } /** * Returns the greatest key strictly less than the given key, or * {@code null} if there is no such key. * @see NavigableMap#lowerKey(Object) */ @Override @QtUninvokable public final Key lowerKey(Key key) { QAssociativeConstIterator iterator = find(key); if(iterator.isValid()) { if(iterator.equals(constBegin())) return null; if(!iterator.equals(constEnd())) iterator.decrement(); }else { iterator = lowerBound(key); if(!iterator.isValid()) return null; } return iterator.checkedKey(); } /** * Returns a key-value mapping associated with the greatest key * less than or equal to the given key, or {@code null} if there * is no such key. * @see NavigableMap#floorEntry(Object) */ @Override @QtUninvokable public final Entry> floorEntry(Key key) { QAssociativeConstIterator iterator = lowerBound(key); if(!iterator.isValid()) return null; else { Key lb = iterator.checkedKey(); return new AbstractMap.SimpleImmutableEntry<>(lb, values(lb)); } } /** * Returns the greatest key less than or equal to the given key, * or {@code null} if there is no such key. * @see NavigableMap#floorKey(Object) */ @Override @QtUninvokable public final Key floorKey(Key key) { return lowerBound(key).key().orElse(null); } /** * Returns a key-value mapping associated with the least key * greater than or equal to the given key, or {@code null} if * there is no such key. * @see NavigableMap#ceilingEntry(Object) */ @Override @QtUninvokable public final Entry> ceilingEntry(Key key) { QAssociativeConstIterator iterator = find(key); if(!iterator.isValid()) iterator = upperBound(key); if(!iterator.isValid()) return null; Key lb = iterator.checkedKey(); return new AbstractMap.SimpleImmutableEntry<>(lb, values(lb)); } /** * Returns the least key greater than or equal to the given key, * or {@code null} if there is no such key. * @see NavigableMap#ceilingKey(Object) */ @Override @QtUninvokable public final Key ceilingKey(Key key) { QAssociativeConstIterator iterator = find(key); if(!iterator.isValid()) iterator = upperBound(key); return iterator.key().orElse(null); } /** * Returns a key-value mapping associated with the least key * strictly greater than the given key, or {@code null} if there * is no such key. * @see NavigableMap#higherEntry(Object) */ @Override @QtUninvokable public final Entry> higherEntry(Key key) { QAssociativeConstIterator iterator = upperBound(key); if(!iterator.isValid()) return null; else { Key lb = iterator.checkedKey(); return new AbstractMap.SimpleImmutableEntry<>(lb, values(lb)); } } /** * Returns the least key strictly greater than the given key, or * {@code null} if there is no such key. * @see NavigableMap#higherKey(Object) */ @Override @QtUninvokable public final Key higherKey(Key key) { return upperBound(key).key().orElse(null); } /** * Returns a key-value mapping associated with the least * key in this map, or {@code null} if the map is empty. * @see NavigableMap#firstEntry() */ @Override @QtUninvokable public final Entry> firstEntry() { if(isEmpty()) return null; else { QAssociativeConstIterator iterator = constBegin(); Key lb = iterator.checkedKey(); return new AbstractMap.SimpleImmutableEntry<>(lb, values(lb)); } } /** * Returns a key-value mapping associated with the greatest * key in this map, or {@code null} if the map is empty. * @see NavigableMap#lastEntry() */ @Override @QtUninvokable public final Entry> lastEntry() { if(isEmpty()) return null; else { QAssociativeConstIterator iterator = constEnd(); iterator.decrement(); Key lb = iterator.checkedKey(); return new AbstractMap.SimpleImmutableEntry<>(lb, values(lb)); } } /** * Removes and returns a key-value mapping associated with * the least key in this map, or {@code null} if the map is empty. * @see NavigableMap#pollFirstEntry() */ @Override @QtUninvokable public final Entry> pollFirstEntry() { Entry> entry = firstEntry(); if(entry!=null) { remove(entry.getKey()); } return entry; } /** * Removes and returns a key-value mapping associated with * the greatest key in this map, or {@code null} if the map is empty. * @see NavigableMap#pollLastEntry() */ @Override @QtUninvokable public final Entry> pollLastEntry() { Entry> entry = lastEntry(); if(entry!=null) { remove(entry.getKey()); } return entry; } /** * Returns a reverse order view of the mappings contained in this map. * @see NavigableMap#descendingMap() */ @Override @QtUninvokable public final NavigableMap> descendingMap() { Comparator comparator = this.comparator(); TreeMap> descendingMap = new TreeMap<>((Key o1, Key o2)-> comparator.compare(o2, o1)); descendingMap.putAll(this); return descendingMap; } /** * Returns a {@link NavigableSet} view of the keys contained in this map. * @see NavigableMap#navigableKeySet() */ @Override @QtUninvokable public final NavigableSet navigableKeySet() { TreeSet set = new TreeSet<>(this.comparator()); set.addAll(this.keySet()); return set; } /** * Returns a reverse order {@link NavigableSet} view of the keys contained in this map. * The set's iterator returns the keys in descending order. * @see NavigableMap#descendingKeySet() */ @Override @QtUninvokable public final NavigableSet descendingKeySet() { Comparator comparator = this.comparator(); TreeSet set = new TreeSet<>((Key o1, Key o2)-> comparator.compare(o2, o1)); set.addAll(this.keySet()); return set; } private static Function> arrayListFactory(){ return key->new ArrayList<>(); } /** * Returns a copy of the portion of this map whose keys range from * {@code fromKey} to {@code toKey}. If {@code fromKey} and * {@code toKey} are equal, the returned map is empty unless * {@code fromInclusive} and {@code toInclusive} are both true. */ @Override @QtUninvokable public final QMultiMap subMap(Key fromKey, boolean fromInclusive, Key toKey, boolean toInclusive) { QMultiMap map = this.clone(); map.clear(); QAssociativeConstIterator k2 = lowerBound(toKey); if(k2.isValid()) { QAssociativeConstIterator k1 = lowerBound(fromKey); if(!fromInclusive) { k1.increment(); } for(; !k1.equals(k2); k1.increment()) { map.insert(k1.checkedKey(), k1.checkedValue()); } if(toInclusive) { map.insert(k2.checkedKey(), k2.checkedValue()); } } return map; } /** * Returns a copy of the portion of this map whose keys are less than (or * equal to, if {@code inclusive} is true) {@code toKey}. */ @Override @QtUninvokable public final QMultiMap headMap(Key toKey, boolean inclusive) { QAssociativeConstIterator k = lowerBound(toKey); QMultiMap map = this.clone(); map.clear(); if(k.isValid()) { for(QAssociativeConstIterator iterator = constBegin(); !iterator.equals(k); iterator.increment()) { map.insert(iterator.checkedKey(), iterator.checkedValue()); } if(inclusive) { map.insert(k.checkedKey(), k.checkedValue()); } } return map; } /** * Returns a copy of the portion of this map whose keys are greater than (or * equal to, if {@code inclusive} is true) {@code fromKey}. */ @Override @QtUninvokable public final QMultiMap tailMap(Key fromKey, boolean inclusive) { QAssociativeConstIterator k = lowerBound(fromKey); QAssociativeConstIterator end = constEnd(); QMultiMap map = this.clone(); map.clear(); if(!k.equals(end)) { if(!inclusive) { k.increment(); } for(;!k.equals(end); k.increment()) { map.insert(k.checkedKey(), k.checkedValue()); } } return map; } /** *

See QMultiMap::operator=(QMultiMap<Key,T>)

*/ @QtUninvokable public final void assign(@StrictNonNull QMultiMap other) { assign(QtJambi_LibraryUtilities.internal.nativeId(this), other, QtJambi_LibraryUtilities.internal.nativeId(other)); } @QtUninvokable private native void assign(long __this__nativeId, Object container, long other); /** *

See QMultiMap::swap(QMultiMap<Key,T>&)

*/ @QtUninvokable public final void swap(@StrictNonNull QMultiMap other) { swap(QtJambi_LibraryUtilities.internal.nativeId(this), other, QtJambi_LibraryUtilities.internal.nativeId(other)); } @QtUninvokable private native void swap(long __this__nativeId, Object container, long other); /** * Returns true of both containers share the same data. */ @QtUninvokable public final boolean isSharedWith(@StrictNonNull QMultiMap other) { return isSharedWith(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.nativeId(other)); } @QtUninvokable private native boolean isSharedWith(long __this__nativeId, long other); /** * Returns true if container is not shared. */ @QtUninvokable public final boolean isDetached() { return isDetached(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native boolean isDetached(long __this__nativeId); /** * Detached the container if it is shared. */ @QtUninvokable public final void detach() { detach(QtJambi_LibraryUtilities.internal.nativeId(this)); } @QtUninvokable private native boolean detach(long __this__nativeId); }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy