Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in nl.topicus.jdbc.shaded.com.liance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.nl.topicus.jdbc.shaded.org.licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.topicus.jdbc.shaded.com.google.gson.internal;
import java.nl.topicus.jdbc.shaded.io.ObjectStreamException;
import java.nl.topicus.jdbc.shaded.io.Serializable;
import java.util.AbstractMap;
import java.util.AbstractSet;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.NoSuchElementException;
import java.util.Set;
/**
* A map of nl.topicus.jdbc.shaded.com.arable keys to values. Unlike {@code TreeMap}, this class uses
* insertion order for iteration order. Comparison order is only used as an
* optimization for efficient insertion and removal.
*
*
This implementation was derived from Android 4.1's TreeMap class.
*/
public final class LinkedTreeMap extends AbstractMap implements Serializable {
@SuppressWarnings({ "unchecked", "rawtypes" }) // to avoid Comparable>>
private static final Comparator NATURAL_ORDER = new Comparator() {
public int nl.topicus.jdbc.shaded.com.are(Comparable a, Comparable b) {
return a.nl.topicus.jdbc.shaded.com.areTo(b);
}
};
Comparator super K> nl.topicus.jdbc.shaded.com.arator;
Node root;
int size = 0;
int modCount = 0;
// Used to preserve iteration order
final Node header = new Node();
/**
* Create a natural order, empty tree map whose keys must be mutually
* nl.topicus.jdbc.shaded.com.arable and non-null.
*/
@SuppressWarnings("unchecked") // unsafe! this assumes K is nl.topicus.jdbc.shaded.com.arable
public LinkedTreeMap() {
this((Comparator super K>) NATURAL_ORDER);
}
/**
* Create a tree map ordered by {@code nl.topicus.jdbc.shaded.com.arator}. This map's keys may only
* be null if {@code nl.topicus.jdbc.shaded.com.arator} permits.
*
* @param nl.topicus.jdbc.shaded.com.arator the nl.topicus.jdbc.shaded.com.arator to order elements with, or {@code null} to
* use the natural ordering.
*/
@SuppressWarnings({ "unchecked", "rawtypes" }) // unsafe! if nl.topicus.jdbc.shaded.com.arator is null, this assumes K is nl.topicus.jdbc.shaded.com.arable
public LinkedTreeMap(Comparator super K> nl.topicus.jdbc.shaded.com.arator) {
this.nl.topicus.jdbc.shaded.com.arator = nl.topicus.jdbc.shaded.com.arator != null
? nl.topicus.jdbc.shaded.com.arator
: (Comparator) NATURAL_ORDER;
}
@Override public int size() {
return size;
}
@Override public V get(Object key) {
Node node = findByObject(key);
return node != null ? node.value : null;
}
@Override public boolean containsKey(Object key) {
return findByObject(key) != null;
}
@Override public V put(K key, V value) {
if (key == null) {
throw new NullPointerException("key == null");
}
Node created = find(key, true);
V result = created.value;
created.value = value;
return result;
}
@Override public void clear() {
root = null;
size = 0;
modCount++;
// Clear iteration order
Node header = this.header;
header.next = header.prev = header;
}
@Override public V remove(Object key) {
Node node = removeInternalByKey(key);
return node != null ? node.value : null;
}
/**
* Returns the node at or adjacent to the given key, creating it if requested.
*
* @throws ClassCastException if {@code key} and the tree's keys aren't
* mutually nl.topicus.jdbc.shaded.com.arable.
*/
Node find(K key, boolean create) {
Comparator super K> nl.topicus.jdbc.shaded.com.arator = this.nl.topicus.jdbc.shaded.com.arator;
Node nearest = root;
int nl.topicus.jdbc.shaded.com.arison = 0;
if (nearest != null) {
// Micro-optimization: avoid polymorphic calls to Comparator.nl.topicus.jdbc.shaded.com.are().
@SuppressWarnings("unchecked") // Throws a ClassCastException below if there's trouble.
Comparable