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 2014 Orient Technologies LTD (info(at)orientechnologies.com)
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.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.
* *
* * For more information: http://www.orientechnologies.com
*
*/
package com.orientechnologies.orient.core.index.mvrbtree;
import java.util.Comparator;
import java.util.Map;
import java.util.SortedMap;
@SuppressWarnings("serial")
public class OMVRBTreeMemory extends OMVRBTree {
/**
* The number of entries in the tree
*/
protected int size = 0;
protected int defaultPageSize = 63;
/**
* Memory based MVRB-Tree implementation. Constructs a new, empty tree map, using the natural ordering of its keys. All keys
* inserted into the map must implement the {@link Comparable} interface. Furthermore, all such keys must be mutually
* comparable: k1.compareTo(k2) must not throw a ClassCastException for any keys k1 and k2
* in the map. If the user attempts to put a key into the map that violates this constraint (for example, the user attempts to put
* a string key into a map whose keys are integers), the put(Object key, Object value) call will throw a
* ClassCastException.
*/
public OMVRBTreeMemory() {
runtimeCheckEnabled = false;
}
public OMVRBTreeMemory(final int iPageSize, final float iLoadFactor) {
this(iPageSize, iLoadFactor, 1);
}
public OMVRBTreeMemory(final int iPageSize, final float iLoadFactor, final int keySize) {
super(keySize);
defaultPageSize = iPageSize;
pageLoadFactor = iLoadFactor;
}
/**
* Constructs a new, empty tree map, ordered according to the given comparator. All keys inserted into the map must be mutually
* comparable by the given comparator: comparator.compare(k1,
* k2) must not throw a ClassCastException for any keys k1 and k2 in the map. If the user attempts
* to put a key into the map that violates this constraint, the put(Object
* key, Object value) call will throw a ClassCastException.
*
* @param comparator
* the comparator that will be used to order this map. If null, the {@linkplain Comparable natural ordering} of
* the keys will be used.
*/
public OMVRBTreeMemory(final Comparator comparator) {
super(comparator);
}
/**
* Constructs a new tree map containing the same mappings as the given map, ordered according to the natural ordering of
* its keys. All keys inserted into the new map must implement the {@link Comparable} interface. Furthermore, all such keys must
* be mutually comparable: k1.compareTo(k2) must not throw a ClassCastException for any keys k1
* and k2 in the map. This method runs in n*log(n) time.
*
* @param m
* the map whose mappings are to be placed in this map
* @throws ClassCastException
* if the keys in m are not {@link Comparable}, or are not mutually comparable
* @throws NullPointerException
* if the specified map is null
*/
public OMVRBTreeMemory(final Map m) {
super(m);
}
/**
* Constructs a new tree map containing the same mappings and using the same ordering as the specified sorted map. This method
* runs in linear time.
*
* @param m
* the sorted map whose mappings are to be placed in this map, and whose comparator is to be used to sort this map
* @throws NullPointerException
* if the specified map is null
*/
public OMVRBTreeMemory(final SortedMap m) {
super(m);
}
@Override
public int getTreeSize() {
return size;
}
protected void setSize(int pSize) {
size = pSize;
}
public int getDefaultPageSize() {
return defaultPageSize;
}
@Override
protected OMVRBTreeEntry createEntry(final K key, final V value) {
return new OMVRBTreeEntryMemory(this, key, value, null);
}
@Override
protected OMVRBTreeEntry createEntry(final OMVRBTreeEntry parent) {
return new OMVRBTreeEntryMemory((OMVRBTreeEntryMemory) parent, parent.getPageSplitItems());
}
}