Skidded
This commit is contained in:
disclearing 2019-02-10 20:13:33 +00:00
parent c18ac7015f
commit 0918e18504
1601 changed files with 430286 additions and 0 deletions

13
.classpath Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/Desktop/HCRoyals/kitmap/plugins/ProtocolLib.jar"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/Desktop/HCRoyals/kitmap/plugins/Vault.jar"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/Desktop/HCRoyals/kitmap/plugins/WorldEdit-6.2.jar"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/Desktop/HCRoyals/Core3/Dependencies/lombok.jar"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/Downloads/Other/Zonix.us/priv/Core/libs/exospigot-1.7.10-1.0.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/.m2/repository/net/milkbowl/vault/VaultAPI/1.4/VaultAPI-1.4.jar"/>
<classpathentry kind="lib" path="C:/Users/Big Blue/Desktop/HCRoyals/Kits/plugins/PermissionsEx.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hFactions</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,48 @@
package compat.com.google.common.collect;
import com.google.common.annotations.*;
import java.util.*;
import javax.annotation.*;
import com.google.common.base.*;
import com.google.common.collect.*;
@GwtCompatible(emulated = true)
public abstract class FluentIterableCompat<E> implements Iterable<E> {
private final Iterable<E> iterable;
@SuppressWarnings("unchecked")
FluentIterableCompat(final Iterable<E> iterable) {
this.iterable = (Iterable<E>) Preconditions.checkNotNull((Object) iterable);
}
@CheckReturnValue
public static <E> FluentIterableCompat<E> from(final Iterable<E> iterable) {
return (iterable instanceof FluentIterableCompat) ? ((FluentIterableCompat<E>) iterable) : new FluentIterableCompat<E>(iterable) {
@Override
public Iterator<E> iterator() {
return iterable.iterator();
}
};
}
@CheckReturnValue
@Override
public String toString() {
return Iterables.toString((Iterable<E>) this.iterable);
}
@CheckReturnValue
public final FluentIterableCompat<E> filter(final Predicate<? super E> predicate) {
return from((Iterable<E>) Iterables.filter((Iterable<E>) this.iterable, (Predicate<? super E>) predicate));
}
@CheckReturnValue
public final <T> FluentIterableCompat<T> transform(final Function<? super E, T> function) {
return from((Iterable<T>) Iterables.transform((Iterable<E>) this.iterable, (Function<? super E, T>) function));
}
@CheckReturnValue
public final ImmutableList<E> toList() {
return (ImmutableList<E>) ImmutableList.copyOf((Iterable<E>) this.iterable);
}
}

View File

@ -0,0 +1,20 @@
package compat.com.google.common.collect;
import com.google.common.base.*;
import javax.annotation.*;
public class GuavaCompat {
public static <T extends Enum<T>> Optional<T> getIfPresent(final Class<T> enumClass, final String value) {
Preconditions.checkNotNull((Object) enumClass);
Preconditions.checkNotNull((Object) value);
try {
return (Optional<T>) Optional.of(Enum.valueOf(enumClass, value));
} catch (IllegalArgumentException iae) {
return Optional.absent();
}
}
public static <T> T firstNonNull(@Nullable final T first, @Nullable final T second) {
return (T) ((first != null) ? first : Preconditions.checkNotNull(second));
}
}

72
src/config.yml Normal file
View File

@ -0,0 +1,72 @@
Scoreboard_title: '&3&lHCRealms &7| &fKits'
Kitmap:
Sharpness: 1
Protection: 1
kits-mode: true
block-in-combat: true
SERVER_NAME: HCRealms
DONATE_URL: store.hcrealms.us
SPAWN_NO_BREAK_RADIUS: 150
WARZONE_RADIUS: 150
NETHER_WARZONE_RADIUS: 300
MAX-FACTION: 25
MAX-ALLY: 0
DEFAULT_DEATHBAN_DURATION: 3600000
WILDERNESS_COLOUR: DARK_GREEN
WARZONE_COLOUR: RED
SAFEZONE_COLOUR: AQUA
TEAMMATE_COLOUR: DARK_GREEN
ALLY_COLOUR: BLUE
ENEMY_COLOUR: RED
ROAD_COLOUR: GOLD
GLOWSTONE_COLOUR: GOLD
COMBATLOG_DESPAWN_DELAY_TICKS: 300
potionLimits:
STRENGTH: 0
INVISIBILITY: 1
REGEN: 0
WEAKNESS: 0
INSTANT_DAMAGE: 0
SLOWNESS: 1
POISON: 1
potionsExtendedDisallowed:
POISON
SLOWNESS
Help:
- '&8&m------------------------------------'
- '&3&lMap Infomation&7:'
- '&7Current Map&8 - &fMap 1'
- '&7Map Border&8 - &f3000'
- '&7Map Kit&8 - &f/mapkit'
- '&8&m------------------------------------'
- '&3&lUseful Commands&7:'
- '&7/coords - &fProvides the coordinates for KoTH Locations'
- '&7/teamspeak - &fProvides the Teamspeak Server IP'
- '&7/rules - &cCurrently Disabled &7(https://hcrealms.us/forums/rules/)'
- '&7/mapkit - &fProvides you with the Map Information on Enchant Limits and Potions'
- '&7/report <Player> <Reason> - &fA command to report rule-breakers'
- '&7/helpop <Message> - &fAlerts online Staff Members that you are in need of
assistance'
- '&8&m------------------------------------'
- '&3&lOther infomation&7:'
- '&7Website&8 - &fwww.hcrealms.us'
- '&7Buycraft&8 - &fstore.hcrealms.us'
- '&7Teamspeak&8 - &fts.hcrealms.us'
- '&8&m------------------------------------'
Teamspeak:
- '&7Teamspeak: &fts.hcrealms.us'
teamspeak-frozen: ts.hcrealms.us
Coords:
- '&8&m----------------------------------------'
- '&6&lCoords'
- '&eSpawn: &70,0 &7(Overworld)'
- '&eNether Spawn: &70,0 &7(Nether)'
- '&eEndPortals: &70,1500,0 &7(All for quads)'
- '&8&m----------------------------------------'
spawn:
world: world
x: 0.538049846829157
y: 69.0
z: 0.6617853658512408
yaw: 0.78689575
pitch: 11.715501

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TByteIterator;
import gnu.trove.procedure.TByteProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TByteCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
byte getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>byte</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( byte entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TByteIterator</code> value
*/
TByteIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
byte[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>byte[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
byte[] toArray( byte[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>byte</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( byte entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>byte</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( byte entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TByteCollection</tt> are present.
*
* @param collection a <code>TByteCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TByteCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of byte primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( byte[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Byte> collection );
/**
* Adds all of the elements in the <tt>TByteCollection</tt> to the collection.
*
* @param collection a <code>TByteCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TByteCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of byte primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( byte[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TByteCollection</tt>.
*
* @param collection a <code>TByteCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TByteCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of byte primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( byte[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TByteCollection</tt> from the collection.
*
* @param collection a <code>TByteCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TByteCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of byte primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( byte[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TByteProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TByteProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TByteCollection

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TCharIterator;
import gnu.trove.procedure.TCharProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TCharCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
char getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>char</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( char entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TCharIterator</code> value
*/
TCharIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
char[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>char[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
char[] toArray( char[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>char</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( char entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>char</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( char entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TCharCollection</tt> are present.
*
* @param collection a <code>TCharCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TCharCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of char primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( char[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Character> collection );
/**
* Adds all of the elements in the <tt>TCharCollection</tt> to the collection.
*
* @param collection a <code>TCharCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TCharCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of char primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( char[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TCharCollection</tt>.
*
* @param collection a <code>TCharCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TCharCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of char primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( char[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TCharCollection</tt> from the collection.
*
* @param collection a <code>TCharCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TCharCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of char primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( char[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TCharProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TCharProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TCharCollection

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,896 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.*;
import gnu.trove.list.*;
import gnu.trove.map.*;
import gnu.trove.set.*;
import gnu.trove.decorator.*;
/**
* This is a static utility class that provides functions for simplifying creation of
* decorators.
*
* @author Robert D. Eden
* @author Jeff Randall
* @since Trove 2.1
*/
public class TDecorators {
// Hide the constructor
private TDecorators() {}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Double> wrap( TDoubleDoubleMap map ) {
return new TDoubleDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Float> wrap( TDoubleFloatMap map ) {
return new TDoubleFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Integer> wrap( TDoubleIntMap map ) {
return new TDoubleIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Long> wrap( TDoubleLongMap map ) {
return new TDoubleLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Byte> wrap( TDoubleByteMap map ) {
return new TDoubleByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Short> wrap( TDoubleShortMap map ) {
return new TDoubleShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Character> wrap( TDoubleCharMap map ) {
return new TDoubleCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Double> wrap( TFloatDoubleMap map ) {
return new TFloatDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Float> wrap( TFloatFloatMap map ) {
return new TFloatFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Integer> wrap( TFloatIntMap map ) {
return new TFloatIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Long> wrap( TFloatLongMap map ) {
return new TFloatLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Byte> wrap( TFloatByteMap map ) {
return new TFloatByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Short> wrap( TFloatShortMap map ) {
return new TFloatShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Character> wrap( TFloatCharMap map ) {
return new TFloatCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Double> wrap( TIntDoubleMap map ) {
return new TIntDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Float> wrap( TIntFloatMap map ) {
return new TIntFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Integer> wrap( TIntIntMap map ) {
return new TIntIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Long> wrap( TIntLongMap map ) {
return new TIntLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Byte> wrap( TIntByteMap map ) {
return new TIntByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Short> wrap( TIntShortMap map ) {
return new TIntShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Character> wrap( TIntCharMap map ) {
return new TIntCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Double> wrap( TLongDoubleMap map ) {
return new TLongDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Float> wrap( TLongFloatMap map ) {
return new TLongFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Integer> wrap( TLongIntMap map ) {
return new TLongIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Long> wrap( TLongLongMap map ) {
return new TLongLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Byte> wrap( TLongByteMap map ) {
return new TLongByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Short> wrap( TLongShortMap map ) {
return new TLongShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Character> wrap( TLongCharMap map ) {
return new TLongCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Double> wrap( TByteDoubleMap map ) {
return new TByteDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Float> wrap( TByteFloatMap map ) {
return new TByteFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Integer> wrap( TByteIntMap map ) {
return new TByteIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Long> wrap( TByteLongMap map ) {
return new TByteLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Byte> wrap( TByteByteMap map ) {
return new TByteByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Short> wrap( TByteShortMap map ) {
return new TByteShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Character> wrap( TByteCharMap map ) {
return new TByteCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Double> wrap( TShortDoubleMap map ) {
return new TShortDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Float> wrap( TShortFloatMap map ) {
return new TShortFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Integer> wrap( TShortIntMap map ) {
return new TShortIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Long> wrap( TShortLongMap map ) {
return new TShortLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Byte> wrap( TShortByteMap map ) {
return new TShortByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Short> wrap( TShortShortMap map ) {
return new TShortShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Character> wrap( TShortCharMap map ) {
return new TShortCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Double> wrap( TCharDoubleMap map ) {
return new TCharDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Float> wrap( TCharFloatMap map ) {
return new TCharFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Integer> wrap( TCharIntMap map ) {
return new TCharIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Long> wrap( TCharLongMap map ) {
return new TCharLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Byte> wrap( TCharByteMap map ) {
return new TCharByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Short> wrap( TCharShortMap map ) {
return new TCharShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Character> wrap( TCharCharMap map ) {
return new TCharCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectDoubleMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Double> wrap( TObjectDoubleMap<T> map ) {
return new TObjectDoubleMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectFloatMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Float> wrap( TObjectFloatMap<T> map ) {
return new TObjectFloatMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectIntMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Integer> wrap( TObjectIntMap<T> map ) {
return new TObjectIntMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectLongMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Long> wrap( TObjectLongMap<T> map ) {
return new TObjectLongMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectByteMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Byte> wrap( TObjectByteMap<T> map ) {
return new TObjectByteMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectShortMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Short> wrap( TObjectShortMap<T> map ) {
return new TObjectShortMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectCharMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Character> wrap( TObjectCharMap<T> map ) {
return new TObjectCharMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Double,T> wrap( TDoubleObjectMap<T> map ) {
return new TDoubleObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Float,T> wrap( TFloatObjectMap<T> map ) {
return new TFloatObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Integer,T> wrap( TIntObjectMap<T> map ) {
return new TIntObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Long,T> wrap( TLongObjectMap<T> map ) {
return new TLongObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Byte,T> wrap( TByteObjectMap<T> map ) {
return new TByteObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Short,T> wrap( TShortObjectMap<T> map ) {
return new TShortObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Character,T> wrap( TCharObjectMap<T> map ) {
return new TCharObjectMapDecorator<T>( map );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TDoubleSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Double> wrap( TDoubleSet set ) {
return new TDoubleSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TFloatSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Float> wrap( TFloatSet set ) {
return new TFloatSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TIntSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Integer> wrap( TIntSet set ) {
return new TIntSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TLongSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Long> wrap( TLongSet set ) {
return new TLongSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TByteSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Byte> wrap( TByteSet set ) {
return new TByteSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TShortSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Short> wrap( TShortSet set ) {
return new TShortSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TCharSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Character> wrap( TCharSet set ) {
return new TCharSetDecorator( set );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TDoubleList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Double> wrap( TDoubleList list ) {
return new TDoubleListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TFloatList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Float> wrap( TFloatList list ) {
return new TFloatListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TIntList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Integer> wrap( TIntList list ) {
return new TIntListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TLongList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Long> wrap( TLongList list ) {
return new TLongListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TByteList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Byte> wrap( TByteList list ) {
return new TByteListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TShortList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Short> wrap( TShortList list ) {
return new TShortListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TCharList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Character> wrap( TCharList list ) {
return new TCharListDecorator( list );
}
}

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TDoubleIterator;
import gnu.trove.procedure.TDoubleProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TDoubleCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
double getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>double</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( double entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TDoubleIterator</code> value
*/
TDoubleIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
double[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>double[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
double[] toArray( double[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>double</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( double entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>double</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( double entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TDoubleCollection</tt> are present.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TDoubleCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of double primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( double[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Double> collection );
/**
* Adds all of the elements in the <tt>TDoubleCollection</tt> to the collection.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TDoubleCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of double primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( double[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TDoubleCollection</tt>.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TDoubleCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of double primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( double[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TDoubleCollection</tt> from the collection.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TDoubleCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of double primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( double[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TDoubleProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TDoubleProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TDoubleCollection

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TFloatIterator;
import gnu.trove.procedure.TFloatProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TFloatCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
float getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>float</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( float entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TFloatIterator</code> value
*/
TFloatIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
float[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>float[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
float[] toArray( float[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>float</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( float entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>float</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( float entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TFloatCollection</tt> are present.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TFloatCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of float primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( float[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Float> collection );
/**
* Adds all of the elements in the <tt>TFloatCollection</tt> to the collection.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TFloatCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of float primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( float[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TFloatCollection</tt>.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TFloatCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of float primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( float[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TFloatCollection</tt> from the collection.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TFloatCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of float primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( float[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TFloatProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TFloatProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TFloatCollection

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TIntIterator;
import gnu.trove.procedure.TIntProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TIntCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
int getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>int</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( int entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TIntIterator</code> value
*/
TIntIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
int[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>int[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
int[] toArray( int[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>int</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( int entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>int</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( int entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TIntCollection</tt> are present.
*
* @param collection a <code>TIntCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TIntCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of int primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( int[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Integer> collection );
/**
* Adds all of the elements in the <tt>TIntCollection</tt> to the collection.
*
* @param collection a <code>TIntCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TIntCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of int primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( int[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TIntCollection</tt>.
*
* @param collection a <code>TIntCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TIntCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of int primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( int[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TIntCollection</tt> from the collection.
*
* @param collection a <code>TIntCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TIntCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of int primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( int[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TIntProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TIntProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TIntCollection

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TLongIterator;
import gnu.trove.procedure.TLongProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TLongCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
long getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>long</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( long entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TLongIterator</code> value
*/
TLongIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
long[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>long[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
long[] toArray( long[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>long</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( long entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>long</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( long entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TLongCollection</tt> are present.
*
* @param collection a <code>TLongCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TLongCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of long primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( long[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Long> collection );
/**
* Adds all of the elements in the <tt>TLongCollection</tt> to the collection.
*
* @param collection a <code>TLongCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TLongCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of long primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( long[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TLongCollection</tt>.
*
* @param collection a <code>TLongCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TLongCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of long primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( long[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TLongCollection</tt> from the collection.
*
* @param collection a <code>TLongCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TLongCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of long primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( long[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TLongProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TLongProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TLongCollection

View File

@ -0,0 +1,316 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.Collection;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TShortIterator;
import gnu.trove.procedure.TShortProcedure;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TShortCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
short getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>short</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( short entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TShortIterator</code> value
*/
TShortIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
short[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>short[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
short[] toArray( short[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>short</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( short entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>short</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( short entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TShortCollection</tt> are present.
*
* @param collection a <code>TShortCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TShortCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of short primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( short[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Short> collection );
/**
* Adds all of the elements in the <tt>TShortCollection</tt> to the collection.
*
* @param collection a <code>TShortCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TShortCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of short primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( short[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TShortCollection</tt>.
*
* @param collection a <code>TShortCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TShortCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of short primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( short[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TShortCollection</tt> from the collection.
*
* @param collection a <code>TShortCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TShortCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of short primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( short[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TShortProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TShortProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TShortCollection

View File

@ -0,0 +1,60 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
/**
* Simple class meant as a possible main class (via manifest) to report the
* implementation version of the trove4j jar.
* <p/>
* This may be useful to ask feedback WITH build version information
* <p/>
* The Main-Class entry in the manifest.mf should be set during the build as well
* as the Implementation-Version manifest attribute should be set as well.
* <p/>
* Created by IntelliJ IDEA.
* User: Johan Parent
* Date: 3/03/11
* Time: 22:10
*/
public class Version {
public static void main(String[] args) {
System.out.println(getVersion());
}
/**
* Returns the implementation version of trove4j. Intended for applications
* wanting to return the version of trove4j they are using
* <p/>
* NOTE: this method will only return a useful version when working
* with a trove4j jar as it requires a manifest file
*
* @return
*/
public static String getVersion() {
String version = Version.class.getPackage().getImplementationVersion();
//
if (version != null) {
return "trove4j version " + version;
}
return "Sorry no Implementation-Version manifest attribute available";
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteByteMap;
import gnu.trove.iterator.TByteByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteByteMapDecorator extends AbstractMap<Byte, Byte>
implements Map<Byte, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteByteMap</tt> to wrap.
*/
public TByteByteMapDecorator( TByteByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteByteMap</tt> instance.
*/
public TByteByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Byte key, Byte value ) {
byte k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteByteMapDecorator.this.containsKey(k)
&& TByteByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Byte>> iterator() {
return new Iterator<Map.Entry<Byte,Byte>>() {
private final TByteByteIterator it = _map.iterator();
public Map.Entry<Byte,Byte> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Byte,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteCharMap;
import gnu.trove.iterator.TByteCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteCharMapDecorator extends AbstractMap<Byte, Character>
implements Map<Byte, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteCharMap</tt> to wrap.
*/
public TByteCharMapDecorator( TByteCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteCharMap</tt> instance.
*/
public TByteCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Byte key, Character value ) {
byte k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Character>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteCharMapDecorator.this.containsKey(k)
&& TByteCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Character>> iterator() {
return new Iterator<Map.Entry<Byte,Character>>() {
private final TByteCharIterator it = _map.iterator();
public Map.Entry<Byte,Character> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Character> map ) {
Iterator<? extends Entry<? extends Byte,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteDoubleMap;
import gnu.trove.iterator.TByteDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteDoubleMapDecorator extends AbstractMap<Byte, Double>
implements Map<Byte, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteDoubleMap</tt> to wrap.
*/
public TByteDoubleMapDecorator( TByteDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteDoubleMap</tt> instance.
*/
public TByteDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Byte key, Double value ) {
byte k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Double>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteDoubleMapDecorator.this.containsKey(k)
&& TByteDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Double>> iterator() {
return new Iterator<Map.Entry<Byte,Double>>() {
private final TByteDoubleIterator it = _map.iterator();
public Map.Entry<Byte,Double> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Double> map ) {
Iterator<? extends Entry<? extends Byte,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteFloatMap;
import gnu.trove.iterator.TByteFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteFloatMapDecorator extends AbstractMap<Byte, Float>
implements Map<Byte, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteFloatMap</tt> to wrap.
*/
public TByteFloatMapDecorator( TByteFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteFloatMap</tt> instance.
*/
public TByteFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Byte key, Float value ) {
byte k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Float>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteFloatMapDecorator.this.containsKey(k)
&& TByteFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Float>> iterator() {
return new Iterator<Map.Entry<Byte,Float>>() {
private final TByteFloatIterator it = _map.iterator();
public Map.Entry<Byte,Float> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Float> map ) {
Iterator<? extends Entry<? extends Byte,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteIntMap;
import gnu.trove.iterator.TByteIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteIntMapDecorator extends AbstractMap<Byte, Integer>
implements Map<Byte, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteIntMap</tt> to wrap.
*/
public TByteIntMapDecorator( TByteIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteIntMap</tt> instance.
*/
public TByteIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Byte key, Integer value ) {
byte k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteIntMapDecorator.this.containsKey(k)
&& TByteIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Integer>> iterator() {
return new Iterator<Map.Entry<Byte,Integer>>() {
private final TByteIntIterator it = _map.iterator();
public Map.Entry<Byte,Integer> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Byte,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TByteList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TByteList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TByteListDecorator extends AbstractList<Byte>
implements List<Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TByteList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TByteList</tt> to wrap.
*/
public TByteListDecorator( TByteList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TByteList</tt> instance.
*/
public TByteList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Byte get( int index ) {
byte value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Byte.valueOf( value );
}
@Override
public Byte set( int index, Byte value ) {
byte previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Byte.valueOf( previous_value );
}
@Override
public void add( int index, Byte value ) {
list.insert( index, value.byteValue() );
}
@Override
public Byte remove( int index ) {
byte previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Byte.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TByteList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteLongMap;
import gnu.trove.iterator.TByteLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteLongMapDecorator extends AbstractMap<Byte, Long>
implements Map<Byte, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteLongMap</tt> to wrap.
*/
public TByteLongMapDecorator( TByteLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteLongMap</tt> instance.
*/
public TByteLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Byte key, Long value ) {
byte k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Long>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteLongMapDecorator.this.containsKey(k)
&& TByteLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Long>> iterator() {
return new Iterator<Map.Entry<Byte,Long>>() {
private final TByteLongIterator it = _map.iterator();
public Map.Entry<Byte,Long> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Long> map ) {
Iterator<? extends Entry<? extends Byte,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteObjectMap;
import gnu.trove.iterator.TByteObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteObjectMapDecorator<V> extends AbstractMap<Byte, V>
implements Map<Byte, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteObjectMap</tt> to wrap.
*/
public TByteObjectMapDecorator( TByteObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteObjectMap</tt> instance.
*/
public TByteObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Byte</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Byte key, V value ) {
byte k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( ( Byte ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( ( Byte ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,V>> entrySet() {
return new AbstractSet<Map.Entry<Byte,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteObjectMapDecorator.this.containsKey( k ) &&
TByteObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,V>> iterator() {
return new Iterator<Map.Entry<Byte,V>>() {
private final TByteObjectIterator<V> it = _map.iterator();
public Map.Entry<Byte,V> next() {
it.advance();
byte k = it.key();
final Byte key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Byte,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Byte getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( ( ( Byte ) key ).byteValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends V> map ) {
Iterator<? extends Entry<? extends Byte,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Byte key ) {
return key.byteValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TByteObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TByteObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TByteSet;
import gnu.trove.iterator.TByteIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TByteSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteSetDecorator extends AbstractSet<Byte>
implements Set<Byte>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TByteSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TByteSet</tt> to wrap.
*/
public TByteSetDecorator( TByteSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TByteSet</tt> instance.
*/
public TByteSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Byte value ) {
return value != null && _set.add( value.byteValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Byte ) {
byte v = ( ( Byte ) val ).byteValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Byte && _set.remove( ( ( Byte ) value ).byteValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Byte> iterator() {
return new Iterator<Byte>() {
private final TByteIterator it = _set.iterator();
public Byte next() {
return Byte.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Byte ) ) return false;
return _set.contains( ( ( Byte ) o ).byteValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TByteSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TByteHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteShortMap;
import gnu.trove.iterator.TByteShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteShortMapDecorator extends AbstractMap<Byte, Short>
implements Map<Byte, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteShortMap</tt> to wrap.
*/
public TByteShortMapDecorator( TByteShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteShortMap</tt> instance.
*/
public TByteShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Byte key, Short value ) {
byte k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Short>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteShortMapDecorator.this.containsKey(k)
&& TByteShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Short>> iterator() {
return new Iterator<Map.Entry<Byte,Short>>() {
private final TByteShortIterator it = _map.iterator();
public Map.Entry<Byte,Short> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Short> map ) {
Iterator<? extends Entry<? extends Byte,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteShortHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharByteMap;
import gnu.trove.iterator.TCharByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharByteMapDecorator extends AbstractMap<Character, Byte>
implements Map<Character, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharByteMap</tt> to wrap.
*/
public TCharByteMapDecorator( TCharByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharByteMap</tt> instance.
*/
public TCharByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Character key, Byte value ) {
char k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Character,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharByteMapDecorator.this.containsKey(k)
&& TCharByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Byte>> iterator() {
return new Iterator<Map.Entry<Character,Byte>>() {
private final TCharByteIterator it = _map.iterator();
public Map.Entry<Character,Byte> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Character,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharCharMap;
import gnu.trove.iterator.TCharCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharCharMapDecorator extends AbstractMap<Character, Character>
implements Map<Character, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharCharMap</tt> to wrap.
*/
public TCharCharMapDecorator( TCharCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharCharMap</tt> instance.
*/
public TCharCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Character key, Character value ) {
char k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Character>> entrySet() {
return new AbstractSet<Map.Entry<Character,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharCharMapDecorator.this.containsKey(k)
&& TCharCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Character>> iterator() {
return new Iterator<Map.Entry<Character,Character>>() {
private final TCharCharIterator it = _map.iterator();
public Map.Entry<Character,Character> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Character> map ) {
Iterator<? extends Entry<? extends Character,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharDoubleMap;
import gnu.trove.iterator.TCharDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharDoubleMapDecorator extends AbstractMap<Character, Double>
implements Map<Character, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharDoubleMap</tt> to wrap.
*/
public TCharDoubleMapDecorator( TCharDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharDoubleMap</tt> instance.
*/
public TCharDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Character key, Double value ) {
char k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Double>> entrySet() {
return new AbstractSet<Map.Entry<Character,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharDoubleMapDecorator.this.containsKey(k)
&& TCharDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Double>> iterator() {
return new Iterator<Map.Entry<Character,Double>>() {
private final TCharDoubleIterator it = _map.iterator();
public Map.Entry<Character,Double> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Double> map ) {
Iterator<? extends Entry<? extends Character,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharFloatMap;
import gnu.trove.iterator.TCharFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharFloatMapDecorator extends AbstractMap<Character, Float>
implements Map<Character, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharFloatMap</tt> to wrap.
*/
public TCharFloatMapDecorator( TCharFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharFloatMap</tt> instance.
*/
public TCharFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Character key, Float value ) {
char k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Float>> entrySet() {
return new AbstractSet<Map.Entry<Character,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharFloatMapDecorator.this.containsKey(k)
&& TCharFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Float>> iterator() {
return new Iterator<Map.Entry<Character,Float>>() {
private final TCharFloatIterator it = _map.iterator();
public Map.Entry<Character,Float> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Float> map ) {
Iterator<? extends Entry<? extends Character,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharIntMap;
import gnu.trove.iterator.TCharIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharIntMapDecorator extends AbstractMap<Character, Integer>
implements Map<Character, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharIntMap</tt> to wrap.
*/
public TCharIntMapDecorator( TCharIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharIntMap</tt> instance.
*/
public TCharIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Character key, Integer value ) {
char k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Character,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharIntMapDecorator.this.containsKey(k)
&& TCharIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Integer>> iterator() {
return new Iterator<Map.Entry<Character,Integer>>() {
private final TCharIntIterator it = _map.iterator();
public Map.Entry<Character,Integer> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Character,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TCharList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TCharList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TCharListDecorator extends AbstractList<Character>
implements List<Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TCharList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TCharList</tt> to wrap.
*/
public TCharListDecorator( TCharList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TCharList</tt> instance.
*/
public TCharList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Character get( int index ) {
char value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Character.valueOf( value );
}
@Override
public Character set( int index, Character value ) {
char previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Character.valueOf( previous_value );
}
@Override
public void add( int index, Character value ) {
list.insert( index, value.charValue() );
}
@Override
public Character remove( int index ) {
char previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Character.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TCharList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharLongMap;
import gnu.trove.iterator.TCharLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharLongMapDecorator extends AbstractMap<Character, Long>
implements Map<Character, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharLongMap</tt> to wrap.
*/
public TCharLongMapDecorator( TCharLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharLongMap</tt> instance.
*/
public TCharLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Character key, Long value ) {
char k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Long>> entrySet() {
return new AbstractSet<Map.Entry<Character,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharLongMapDecorator.this.containsKey(k)
&& TCharLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Long>> iterator() {
return new Iterator<Map.Entry<Character,Long>>() {
private final TCharLongIterator it = _map.iterator();
public Map.Entry<Character,Long> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Long> map ) {
Iterator<? extends Entry<? extends Character,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharObjectMap;
import gnu.trove.iterator.TCharObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharObjectMapDecorator<V> extends AbstractMap<Character, V>
implements Map<Character, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharObjectMap</tt> to wrap.
*/
public TCharObjectMapDecorator( TCharObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharObjectMap</tt> instance.
*/
public TCharObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Character</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Character key, V value ) {
char k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( ( Character ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( ( Character ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,V>> entrySet() {
return new AbstractSet<Map.Entry<Character,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharObjectMapDecorator.this.containsKey( k ) &&
TCharObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Character,V>> iterator() {
return new Iterator<Map.Entry<Character,V>>() {
private final TCharObjectIterator<V> it = _map.iterator();
public Map.Entry<Character,V> next() {
it.advance();
char k = it.key();
final Character key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Character,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Character getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( ( ( Character ) key ).charValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends V> map ) {
Iterator<? extends Entry<? extends Character,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Character key ) {
return key.charValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TCharObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TCharObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TCharSet;
import gnu.trove.iterator.TCharIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TCharSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharSetDecorator extends AbstractSet<Character>
implements Set<Character>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TCharSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TCharSet</tt> to wrap.
*/
public TCharSetDecorator( TCharSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TCharSet</tt> instance.
*/
public TCharSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Character value ) {
return value != null && _set.add( value.charValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Character ) {
char v = ( ( Character ) val ).charValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Character && _set.remove( ( ( Character ) value ).charValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Character> iterator() {
return new Iterator<Character>() {
private final TCharIterator it = _set.iterator();
public Character next() {
return Character.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Character ) ) return false;
return _set.contains( ( ( Character ) o ).charValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TCharSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TCharHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TCharShortMap;
import gnu.trove.iterator.TCharShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TCharShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TCharShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TCharShortMapDecorator extends AbstractMap<Character, Short>
implements Map<Character, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TCharShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TCharShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TCharShortMap</tt> to wrap.
*/
public TCharShortMapDecorator( TCharShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TCharShortMap</tt> instance.
*/
public TCharShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Character key, Short value ) {
char k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
char k;
if ( key != null ) {
if ( key instanceof Character ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Character,Short>> entrySet() {
return new AbstractSet<Map.Entry<Character,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TCharShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TCharShortMapDecorator.this.containsKey(k)
&& TCharShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Character,Short>> iterator() {
return new Iterator<Map.Entry<Character,Short>>() {
private final TCharShortIterator it = _map.iterator();
public Map.Entry<Character,Short> next() {
it.advance();
char ik = it.key();
final Character key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Character,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Character getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Character,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Character key = ( ( Map.Entry<Character,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Character, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TCharShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Character && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Character, ? extends Short> map ) {
Iterator<? extends Entry<? extends Character,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Character,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Character wrapKey( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected char unwrapKey( Object key ) {
return ( ( Character ) key ).charValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TCharShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TCharShortHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleByteMap;
import gnu.trove.iterator.TDoubleByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleByteMapDecorator extends AbstractMap<Double, Byte>
implements Map<Double, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleByteMap</tt> to wrap.
*/
public TDoubleByteMapDecorator( TDoubleByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleByteMap</tt> instance.
*/
public TDoubleByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Double key, Byte value ) {
double k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Double,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleByteMapDecorator.this.containsKey(k)
&& TDoubleByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Byte>> iterator() {
return new Iterator<Map.Entry<Double,Byte>>() {
private final TDoubleByteIterator it = _map.iterator();
public Map.Entry<Double,Byte> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Double,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleCharMap;
import gnu.trove.iterator.TDoubleCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleCharMapDecorator extends AbstractMap<Double, Character>
implements Map<Double, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleCharMap</tt> to wrap.
*/
public TDoubleCharMapDecorator( TDoubleCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleCharMap</tt> instance.
*/
public TDoubleCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Double key, Character value ) {
double k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Character>> entrySet() {
return new AbstractSet<Map.Entry<Double,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleCharMapDecorator.this.containsKey(k)
&& TDoubleCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Character>> iterator() {
return new Iterator<Map.Entry<Double,Character>>() {
private final TDoubleCharIterator it = _map.iterator();
public Map.Entry<Double,Character> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Character> map ) {
Iterator<? extends Entry<? extends Double,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleDoubleMap;
import gnu.trove.iterator.TDoubleDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleDoubleMapDecorator extends AbstractMap<Double, Double>
implements Map<Double, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleDoubleMap</tt> to wrap.
*/
public TDoubleDoubleMapDecorator( TDoubleDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleDoubleMap</tt> instance.
*/
public TDoubleDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Double key, Double value ) {
double k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Double>> entrySet() {
return new AbstractSet<Map.Entry<Double,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleDoubleMapDecorator.this.containsKey(k)
&& TDoubleDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Double>> iterator() {
return new Iterator<Map.Entry<Double,Double>>() {
private final TDoubleDoubleIterator it = _map.iterator();
public Map.Entry<Double,Double> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Double> map ) {
Iterator<? extends Entry<? extends Double,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleFloatMap;
import gnu.trove.iterator.TDoubleFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleFloatMapDecorator extends AbstractMap<Double, Float>
implements Map<Double, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleFloatMap</tt> to wrap.
*/
public TDoubleFloatMapDecorator( TDoubleFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleFloatMap</tt> instance.
*/
public TDoubleFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Double key, Float value ) {
double k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Float>> entrySet() {
return new AbstractSet<Map.Entry<Double,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleFloatMapDecorator.this.containsKey(k)
&& TDoubleFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Float>> iterator() {
return new Iterator<Map.Entry<Double,Float>>() {
private final TDoubleFloatIterator it = _map.iterator();
public Map.Entry<Double,Float> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Float> map ) {
Iterator<? extends Entry<? extends Double,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleIntMap;
import gnu.trove.iterator.TDoubleIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleIntMapDecorator extends AbstractMap<Double, Integer>
implements Map<Double, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleIntMap</tt> to wrap.
*/
public TDoubleIntMapDecorator( TDoubleIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleIntMap</tt> instance.
*/
public TDoubleIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Double key, Integer value ) {
double k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Double,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleIntMapDecorator.this.containsKey(k)
&& TDoubleIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Integer>> iterator() {
return new Iterator<Map.Entry<Double,Integer>>() {
private final TDoubleIntIterator it = _map.iterator();
public Map.Entry<Double,Integer> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Double,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TDoubleList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TDoubleList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TDoubleListDecorator extends AbstractList<Double>
implements List<Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TDoubleList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TDoubleList</tt> to wrap.
*/
public TDoubleListDecorator( TDoubleList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleList</tt> instance.
*/
public TDoubleList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Double get( int index ) {
double value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Double.valueOf( value );
}
@Override
public Double set( int index, Double value ) {
double previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Double.valueOf( previous_value );
}
@Override
public void add( int index, Double value ) {
list.insert( index, value.doubleValue() );
}
@Override
public Double remove( int index ) {
double previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Double.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TDoubleList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleLongMap;
import gnu.trove.iterator.TDoubleLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleLongMapDecorator extends AbstractMap<Double, Long>
implements Map<Double, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleLongMap</tt> to wrap.
*/
public TDoubleLongMapDecorator( TDoubleLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleLongMap</tt> instance.
*/
public TDoubleLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Double key, Long value ) {
double k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Long>> entrySet() {
return new AbstractSet<Map.Entry<Double,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleLongMapDecorator.this.containsKey(k)
&& TDoubleLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Long>> iterator() {
return new Iterator<Map.Entry<Double,Long>>() {
private final TDoubleLongIterator it = _map.iterator();
public Map.Entry<Double,Long> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Long> map ) {
Iterator<? extends Entry<? extends Double,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleObjectMap;
import gnu.trove.iterator.TDoubleObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleObjectMapDecorator<V> extends AbstractMap<Double, V>
implements Map<Double, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleObjectMap</tt> to wrap.
*/
public TDoubleObjectMapDecorator( TDoubleObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleObjectMap</tt> instance.
*/
public TDoubleObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Double</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Double key, V value ) {
double k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( ( Double ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( ( Double ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,V>> entrySet() {
return new AbstractSet<Map.Entry<Double,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleObjectMapDecorator.this.containsKey( k ) &&
TDoubleObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Double,V>> iterator() {
return new Iterator<Map.Entry<Double,V>>() {
private final TDoubleObjectIterator<V> it = _map.iterator();
public Map.Entry<Double,V> next() {
it.advance();
double k = it.key();
final Double key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Double,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Double getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( ( ( Double ) key ).doubleValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends V> map ) {
Iterator<? extends Entry<? extends Double,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Double key ) {
return key.doubleValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TDoubleObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TDoubleObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TDoubleSet;
import gnu.trove.iterator.TDoubleIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TDoubleSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleSetDecorator extends AbstractSet<Double>
implements Set<Double>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TDoubleSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TDoubleSet</tt> to wrap.
*/
public TDoubleSetDecorator( TDoubleSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleSet</tt> instance.
*/
public TDoubleSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Double value ) {
return value != null && _set.add( value.doubleValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Double ) {
double v = ( ( Double ) val ).doubleValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Double && _set.remove( ( ( Double ) value ).doubleValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Double> iterator() {
return new Iterator<Double>() {
private final TDoubleIterator it = _set.iterator();
public Double next() {
return Double.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Double ) ) return false;
return _set.contains( ( ( Double ) o ).doubleValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TDoubleSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TDoubleHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TDoubleShortMap;
import gnu.trove.iterator.TDoubleShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TDoubleShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TDoubleShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TDoubleShortMapDecorator extends AbstractMap<Double, Short>
implements Map<Double, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TDoubleShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TDoubleShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TDoubleShortMap</tt> to wrap.
*/
public TDoubleShortMapDecorator( TDoubleShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TDoubleShortMap</tt> instance.
*/
public TDoubleShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Double key, Short value ) {
double k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
double k;
if ( key != null ) {
if ( key instanceof Double ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Double,Short>> entrySet() {
return new AbstractSet<Map.Entry<Double,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TDoubleShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TDoubleShortMapDecorator.this.containsKey(k)
&& TDoubleShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Double,Short>> iterator() {
return new Iterator<Map.Entry<Double,Short>>() {
private final TDoubleShortIterator it = _map.iterator();
public Map.Entry<Double,Short> next() {
it.advance();
double ik = it.key();
final Double key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Double,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Double getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Double,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Double key = ( ( Map.Entry<Double,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Double, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TDoubleShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Double && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Double, ? extends Short> map ) {
Iterator<? extends Entry<? extends Double,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Double,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Double wrapKey( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected double unwrapKey( Object key ) {
return ( ( Double ) key ).doubleValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TDoubleShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TDoubleShortHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatByteMap;
import gnu.trove.iterator.TFloatByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatByteMapDecorator extends AbstractMap<Float, Byte>
implements Map<Float, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatByteMap</tt> to wrap.
*/
public TFloatByteMapDecorator( TFloatByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatByteMap</tt> instance.
*/
public TFloatByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Float key, Byte value ) {
float k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Float,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatByteMapDecorator.this.containsKey(k)
&& TFloatByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Byte>> iterator() {
return new Iterator<Map.Entry<Float,Byte>>() {
private final TFloatByteIterator it = _map.iterator();
public Map.Entry<Float,Byte> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Float,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatCharMap;
import gnu.trove.iterator.TFloatCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatCharMapDecorator extends AbstractMap<Float, Character>
implements Map<Float, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatCharMap</tt> to wrap.
*/
public TFloatCharMapDecorator( TFloatCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatCharMap</tt> instance.
*/
public TFloatCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Float key, Character value ) {
float k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Character>> entrySet() {
return new AbstractSet<Map.Entry<Float,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatCharMapDecorator.this.containsKey(k)
&& TFloatCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Character>> iterator() {
return new Iterator<Map.Entry<Float,Character>>() {
private final TFloatCharIterator it = _map.iterator();
public Map.Entry<Float,Character> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Character> map ) {
Iterator<? extends Entry<? extends Float,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatDoubleMap;
import gnu.trove.iterator.TFloatDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatDoubleMapDecorator extends AbstractMap<Float, Double>
implements Map<Float, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatDoubleMap</tt> to wrap.
*/
public TFloatDoubleMapDecorator( TFloatDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatDoubleMap</tt> instance.
*/
public TFloatDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Float key, Double value ) {
float k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Double>> entrySet() {
return new AbstractSet<Map.Entry<Float,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatDoubleMapDecorator.this.containsKey(k)
&& TFloatDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Double>> iterator() {
return new Iterator<Map.Entry<Float,Double>>() {
private final TFloatDoubleIterator it = _map.iterator();
public Map.Entry<Float,Double> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Double> map ) {
Iterator<? extends Entry<? extends Float,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatFloatMap;
import gnu.trove.iterator.TFloatFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatFloatMapDecorator extends AbstractMap<Float, Float>
implements Map<Float, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatFloatMap</tt> to wrap.
*/
public TFloatFloatMapDecorator( TFloatFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatFloatMap</tt> instance.
*/
public TFloatFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Float key, Float value ) {
float k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Float>> entrySet() {
return new AbstractSet<Map.Entry<Float,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatFloatMapDecorator.this.containsKey(k)
&& TFloatFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Float>> iterator() {
return new Iterator<Map.Entry<Float,Float>>() {
private final TFloatFloatIterator it = _map.iterator();
public Map.Entry<Float,Float> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Float> map ) {
Iterator<? extends Entry<? extends Float,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatIntMap;
import gnu.trove.iterator.TFloatIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatIntMapDecorator extends AbstractMap<Float, Integer>
implements Map<Float, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatIntMap</tt> to wrap.
*/
public TFloatIntMapDecorator( TFloatIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatIntMap</tt> instance.
*/
public TFloatIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Float key, Integer value ) {
float k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Float,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatIntMapDecorator.this.containsKey(k)
&& TFloatIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Integer>> iterator() {
return new Iterator<Map.Entry<Float,Integer>>() {
private final TFloatIntIterator it = _map.iterator();
public Map.Entry<Float,Integer> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Float,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TFloatList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TFloatList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TFloatListDecorator extends AbstractList<Float>
implements List<Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TFloatList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TFloatList</tt> to wrap.
*/
public TFloatListDecorator( TFloatList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TFloatList</tt> instance.
*/
public TFloatList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Float get( int index ) {
float value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Float.valueOf( value );
}
@Override
public Float set( int index, Float value ) {
float previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Float.valueOf( previous_value );
}
@Override
public void add( int index, Float value ) {
list.insert( index, value.floatValue() );
}
@Override
public Float remove( int index ) {
float previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Float.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TFloatList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatLongMap;
import gnu.trove.iterator.TFloatLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatLongMapDecorator extends AbstractMap<Float, Long>
implements Map<Float, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatLongMap</tt> to wrap.
*/
public TFloatLongMapDecorator( TFloatLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatLongMap</tt> instance.
*/
public TFloatLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Float key, Long value ) {
float k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Long>> entrySet() {
return new AbstractSet<Map.Entry<Float,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatLongMapDecorator.this.containsKey(k)
&& TFloatLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Long>> iterator() {
return new Iterator<Map.Entry<Float,Long>>() {
private final TFloatLongIterator it = _map.iterator();
public Map.Entry<Float,Long> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Long> map ) {
Iterator<? extends Entry<? extends Float,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatObjectMap;
import gnu.trove.iterator.TFloatObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatObjectMapDecorator<V> extends AbstractMap<Float, V>
implements Map<Float, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatObjectMap</tt> to wrap.
*/
public TFloatObjectMapDecorator( TFloatObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatObjectMap</tt> instance.
*/
public TFloatObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Float</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Float key, V value ) {
float k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( ( Float ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( ( Float ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,V>> entrySet() {
return new AbstractSet<Map.Entry<Float,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatObjectMapDecorator.this.containsKey( k ) &&
TFloatObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Float,V>> iterator() {
return new Iterator<Map.Entry<Float,V>>() {
private final TFloatObjectIterator<V> it = _map.iterator();
public Map.Entry<Float,V> next() {
it.advance();
float k = it.key();
final Float key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Float,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Float getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( ( ( Float ) key ).floatValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends V> map ) {
Iterator<? extends Entry<? extends Float,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Float key ) {
return key.floatValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TFloatObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TFloatObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TFloatSet;
import gnu.trove.iterator.TFloatIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TFloatSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatSetDecorator extends AbstractSet<Float>
implements Set<Float>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TFloatSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TFloatSet</tt> to wrap.
*/
public TFloatSetDecorator( TFloatSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TFloatSet</tt> instance.
*/
public TFloatSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Float value ) {
return value != null && _set.add( value.floatValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Float ) {
float v = ( ( Float ) val ).floatValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Float && _set.remove( ( ( Float ) value ).floatValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Float> iterator() {
return new Iterator<Float>() {
private final TFloatIterator it = _set.iterator();
public Float next() {
return Float.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Float ) ) return false;
return _set.contains( ( ( Float ) o ).floatValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TFloatSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TFloatHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TFloatShortMap;
import gnu.trove.iterator.TFloatShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TFloatShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TFloatShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TFloatShortMapDecorator extends AbstractMap<Float, Short>
implements Map<Float, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TFloatShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TFloatShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TFloatShortMap</tt> to wrap.
*/
public TFloatShortMapDecorator( TFloatShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TFloatShortMap</tt> instance.
*/
public TFloatShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Float key, Short value ) {
float k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
float k;
if ( key != null ) {
if ( key instanceof Float ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Float,Short>> entrySet() {
return new AbstractSet<Map.Entry<Float,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TFloatShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TFloatShortMapDecorator.this.containsKey(k)
&& TFloatShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Float,Short>> iterator() {
return new Iterator<Map.Entry<Float,Short>>() {
private final TFloatShortIterator it = _map.iterator();
public Map.Entry<Float,Short> next() {
it.advance();
float ik = it.key();
final Float key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Float,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Float getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Float,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Float key = ( ( Map.Entry<Float,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Float, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TFloatShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Float && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Float, ? extends Short> map ) {
Iterator<? extends Entry<? extends Float,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Float,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Float wrapKey( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected float unwrapKey( Object key ) {
return ( ( Float ) key ).floatValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TFloatShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TFloatShortHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntByteMap;
import gnu.trove.iterator.TIntByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntByteMapDecorator extends AbstractMap<Integer, Byte>
implements Map<Integer, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntByteMap</tt> to wrap.
*/
public TIntByteMapDecorator( TIntByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntByteMap</tt> instance.
*/
public TIntByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Integer key, Byte value ) {
int k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntByteMapDecorator.this.containsKey(k)
&& TIntByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Byte>> iterator() {
return new Iterator<Map.Entry<Integer,Byte>>() {
private final TIntByteIterator it = _map.iterator();
public Map.Entry<Integer,Byte> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Integer,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntCharMap;
import gnu.trove.iterator.TIntCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntCharMapDecorator extends AbstractMap<Integer, Character>
implements Map<Integer, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntCharMap</tt> to wrap.
*/
public TIntCharMapDecorator( TIntCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntCharMap</tt> instance.
*/
public TIntCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Integer key, Character value ) {
int k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Character>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntCharMapDecorator.this.containsKey(k)
&& TIntCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Character>> iterator() {
return new Iterator<Map.Entry<Integer,Character>>() {
private final TIntCharIterator it = _map.iterator();
public Map.Entry<Integer,Character> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Character> map ) {
Iterator<? extends Entry<? extends Integer,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntDoubleMap;
import gnu.trove.iterator.TIntDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntDoubleMapDecorator extends AbstractMap<Integer, Double>
implements Map<Integer, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntDoubleMap</tt> to wrap.
*/
public TIntDoubleMapDecorator( TIntDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntDoubleMap</tt> instance.
*/
public TIntDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Integer key, Double value ) {
int k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Double>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntDoubleMapDecorator.this.containsKey(k)
&& TIntDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Double>> iterator() {
return new Iterator<Map.Entry<Integer,Double>>() {
private final TIntDoubleIterator it = _map.iterator();
public Map.Entry<Integer,Double> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Double> map ) {
Iterator<? extends Entry<? extends Integer,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntFloatMap;
import gnu.trove.iterator.TIntFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntFloatMapDecorator extends AbstractMap<Integer, Float>
implements Map<Integer, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntFloatMap</tt> to wrap.
*/
public TIntFloatMapDecorator( TIntFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntFloatMap</tt> instance.
*/
public TIntFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Integer key, Float value ) {
int k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Float>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntFloatMapDecorator.this.containsKey(k)
&& TIntFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Float>> iterator() {
return new Iterator<Map.Entry<Integer,Float>>() {
private final TIntFloatIterator it = _map.iterator();
public Map.Entry<Integer,Float> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Float> map ) {
Iterator<? extends Entry<? extends Integer,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntIntMap;
import gnu.trove.iterator.TIntIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntIntMapDecorator extends AbstractMap<Integer, Integer>
implements Map<Integer, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntIntMap</tt> to wrap.
*/
public TIntIntMapDecorator( TIntIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntIntMap</tt> instance.
*/
public TIntIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Integer key, Integer value ) {
int k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntIntMapDecorator.this.containsKey(k)
&& TIntIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Integer>> iterator() {
return new Iterator<Map.Entry<Integer,Integer>>() {
private final TIntIntIterator it = _map.iterator();
public Map.Entry<Integer,Integer> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Integer,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TIntList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TIntList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TIntListDecorator extends AbstractList<Integer>
implements List<Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TIntList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TIntList</tt> to wrap.
*/
public TIntListDecorator( TIntList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TIntList</tt> instance.
*/
public TIntList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Integer get( int index ) {
int value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Integer.valueOf( value );
}
@Override
public Integer set( int index, Integer value ) {
int previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Integer.valueOf( previous_value );
}
@Override
public void add( int index, Integer value ) {
list.insert( index, value.intValue() );
}
@Override
public Integer remove( int index ) {
int previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Integer.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TIntList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntLongMap;
import gnu.trove.iterator.TIntLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntLongMapDecorator extends AbstractMap<Integer, Long>
implements Map<Integer, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntLongMap</tt> to wrap.
*/
public TIntLongMapDecorator( TIntLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntLongMap</tt> instance.
*/
public TIntLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Integer key, Long value ) {
int k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Long>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntLongMapDecorator.this.containsKey(k)
&& TIntLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Long>> iterator() {
return new Iterator<Map.Entry<Integer,Long>>() {
private final TIntLongIterator it = _map.iterator();
public Map.Entry<Integer,Long> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Long> map ) {
Iterator<? extends Entry<? extends Integer,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.iterator.TIntObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntObjectMapDecorator<V> extends AbstractMap<Integer, V>
implements Map<Integer, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntObjectMap</tt> to wrap.
*/
public TIntObjectMapDecorator( TIntObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntObjectMap</tt> instance.
*/
public TIntObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Integer</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Integer key, V value ) {
int k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( ( Integer ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( ( Integer ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,V>> entrySet() {
return new AbstractSet<Map.Entry<Integer,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntObjectMapDecorator.this.containsKey( k ) &&
TIntObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,V>> iterator() {
return new Iterator<Map.Entry<Integer,V>>() {
private final TIntObjectIterator<V> it = _map.iterator();
public Map.Entry<Integer,V> next() {
it.advance();
int k = it.key();
final Integer key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Integer,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Integer getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( ( ( Integer ) key ).intValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends V> map ) {
Iterator<? extends Entry<? extends Integer,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Integer key ) {
return key.intValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TIntObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TIntObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TIntSet;
import gnu.trove.iterator.TIntIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TIntSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntSetDecorator extends AbstractSet<Integer>
implements Set<Integer>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TIntSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TIntSet</tt> to wrap.
*/
public TIntSetDecorator( TIntSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TIntSet</tt> instance.
*/
public TIntSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Integer value ) {
return value != null && _set.add( value.intValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Integer ) {
int v = ( ( Integer ) val ).intValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Integer && _set.remove( ( ( Integer ) value ).intValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Integer> iterator() {
return new Iterator<Integer>() {
private final TIntIterator it = _set.iterator();
public Integer next() {
return Integer.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Integer ) ) return false;
return _set.contains( ( ( Integer ) o ).intValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TIntSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TIntHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TIntShortMap;
import gnu.trove.iterator.TIntShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TIntShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TIntShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TIntShortMapDecorator extends AbstractMap<Integer, Short>
implements Map<Integer, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TIntShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TIntShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TIntShortMap</tt> to wrap.
*/
public TIntShortMapDecorator( TIntShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TIntShortMap</tt> instance.
*/
public TIntShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Integer key, Short value ) {
int k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
int k;
if ( key != null ) {
if ( key instanceof Integer ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Integer,Short>> entrySet() {
return new AbstractSet<Map.Entry<Integer,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TIntShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TIntShortMapDecorator.this.containsKey(k)
&& TIntShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Integer,Short>> iterator() {
return new Iterator<Map.Entry<Integer,Short>>() {
private final TIntShortIterator it = _map.iterator();
public Map.Entry<Integer,Short> next() {
it.advance();
int ik = it.key();
final Integer key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Integer,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Integer getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Integer,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Integer key = ( ( Map.Entry<Integer,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Integer, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TIntShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Integer && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Integer, ? extends Short> map ) {
Iterator<? extends Entry<? extends Integer,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Integer,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Integer wrapKey( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected int unwrapKey( Object key ) {
return ( ( Integer ) key ).intValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TIntShortHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongByteMap;
import gnu.trove.iterator.TLongByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongByteMapDecorator extends AbstractMap<Long, Byte>
implements Map<Long, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongByteMap</tt> to wrap.
*/
public TLongByteMapDecorator( TLongByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongByteMap</tt> instance.
*/
public TLongByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Long key, Byte value ) {
long k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Long,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongByteMapDecorator.this.containsKey(k)
&& TLongByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Byte>> iterator() {
return new Iterator<Map.Entry<Long,Byte>>() {
private final TLongByteIterator it = _map.iterator();
public Map.Entry<Long,Byte> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Long,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongCharMap;
import gnu.trove.iterator.TLongCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongCharMapDecorator extends AbstractMap<Long, Character>
implements Map<Long, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongCharMap</tt> to wrap.
*/
public TLongCharMapDecorator( TLongCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongCharMap</tt> instance.
*/
public TLongCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Long key, Character value ) {
long k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Character>> entrySet() {
return new AbstractSet<Map.Entry<Long,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongCharMapDecorator.this.containsKey(k)
&& TLongCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Character>> iterator() {
return new Iterator<Map.Entry<Long,Character>>() {
private final TLongCharIterator it = _map.iterator();
public Map.Entry<Long,Character> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Character> map ) {
Iterator<? extends Entry<? extends Long,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongDoubleMap;
import gnu.trove.iterator.TLongDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongDoubleMapDecorator extends AbstractMap<Long, Double>
implements Map<Long, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongDoubleMap</tt> to wrap.
*/
public TLongDoubleMapDecorator( TLongDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongDoubleMap</tt> instance.
*/
public TLongDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Long key, Double value ) {
long k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Double>> entrySet() {
return new AbstractSet<Map.Entry<Long,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongDoubleMapDecorator.this.containsKey(k)
&& TLongDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Double>> iterator() {
return new Iterator<Map.Entry<Long,Double>>() {
private final TLongDoubleIterator it = _map.iterator();
public Map.Entry<Long,Double> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Double> map ) {
Iterator<? extends Entry<? extends Long,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongFloatMap;
import gnu.trove.iterator.TLongFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongFloatMapDecorator extends AbstractMap<Long, Float>
implements Map<Long, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongFloatMap</tt> to wrap.
*/
public TLongFloatMapDecorator( TLongFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongFloatMap</tt> instance.
*/
public TLongFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Long key, Float value ) {
long k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Float>> entrySet() {
return new AbstractSet<Map.Entry<Long,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongFloatMapDecorator.this.containsKey(k)
&& TLongFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Float>> iterator() {
return new Iterator<Map.Entry<Long,Float>>() {
private final TLongFloatIterator it = _map.iterator();
public Map.Entry<Long,Float> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Float> map ) {
Iterator<? extends Entry<? extends Long,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongIntMap;
import gnu.trove.iterator.TLongIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongIntMapDecorator extends AbstractMap<Long, Integer>
implements Map<Long, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongIntMap</tt> to wrap.
*/
public TLongIntMapDecorator( TLongIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongIntMap</tt> instance.
*/
public TLongIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Long key, Integer value ) {
long k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Long,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongIntMapDecorator.this.containsKey(k)
&& TLongIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Integer>> iterator() {
return new Iterator<Map.Entry<Long,Integer>>() {
private final TLongIntIterator it = _map.iterator();
public Map.Entry<Long,Integer> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Long,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TLongList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TLongList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TLongListDecorator extends AbstractList<Long>
implements List<Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TLongList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TLongList</tt> to wrap.
*/
public TLongListDecorator( TLongList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TLongList</tt> instance.
*/
public TLongList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Long get( int index ) {
long value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Long.valueOf( value );
}
@Override
public Long set( int index, Long value ) {
long previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Long.valueOf( previous_value );
}
@Override
public void add( int index, Long value ) {
list.insert( index, value.longValue() );
}
@Override
public Long remove( int index ) {
long previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Long.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TLongList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongLongMap;
import gnu.trove.iterator.TLongLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongLongMapDecorator extends AbstractMap<Long, Long>
implements Map<Long, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongLongMap</tt> to wrap.
*/
public TLongLongMapDecorator( TLongLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongLongMap</tt> instance.
*/
public TLongLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Long key, Long value ) {
long k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Long>> entrySet() {
return new AbstractSet<Map.Entry<Long,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongLongMapDecorator.this.containsKey(k)
&& TLongLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Long>> iterator() {
return new Iterator<Map.Entry<Long,Long>>() {
private final TLongLongIterator it = _map.iterator();
public Map.Entry<Long,Long> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Long> map ) {
Iterator<? extends Entry<? extends Long,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongObjectMap;
import gnu.trove.iterator.TLongObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongObjectMapDecorator<V> extends AbstractMap<Long, V>
implements Map<Long, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongObjectMap</tt> to wrap.
*/
public TLongObjectMapDecorator( TLongObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongObjectMap</tt> instance.
*/
public TLongObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Long</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Long key, V value ) {
long k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( ( Long ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( ( Long ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,V>> entrySet() {
return new AbstractSet<Map.Entry<Long,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongObjectMapDecorator.this.containsKey( k ) &&
TLongObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Long,V>> iterator() {
return new Iterator<Map.Entry<Long,V>>() {
private final TLongObjectIterator<V> it = _map.iterator();
public Map.Entry<Long,V> next() {
it.advance();
long k = it.key();
final Long key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Long,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Long getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( ( ( Long ) key ).longValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends V> map ) {
Iterator<? extends Entry<? extends Long,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Long key ) {
return key.longValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TLongObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TLongObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TLongSet;
import gnu.trove.iterator.TLongIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TLongSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongSetDecorator extends AbstractSet<Long>
implements Set<Long>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TLongSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TLongSet</tt> to wrap.
*/
public TLongSetDecorator( TLongSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TLongSet</tt> instance.
*/
public TLongSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Long value ) {
return value != null && _set.add( value.longValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Long ) {
long v = ( ( Long ) val ).longValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Long && _set.remove( ( ( Long ) value ).longValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Long> iterator() {
return new Iterator<Long>() {
private final TLongIterator it = _set.iterator();
public Long next() {
return Long.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Long ) ) return false;
return _set.contains( ( ( Long ) o ).longValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TLongSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TLongHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TLongShortMap;
import gnu.trove.iterator.TLongShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TLongShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TLongShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TLongShortMapDecorator extends AbstractMap<Long, Short>
implements Map<Long, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TLongShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TLongShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongShortMap</tt> to wrap.
*/
public TLongShortMapDecorator( TLongShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TLongShortMap</tt> instance.
*/
public TLongShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Long key, Short value ) {
long k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
long k;
if ( key != null ) {
if ( key instanceof Long ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Long,Short>> entrySet() {
return new AbstractSet<Map.Entry<Long,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TLongShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TLongShortMapDecorator.this.containsKey(k)
&& TLongShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Long,Short>> iterator() {
return new Iterator<Map.Entry<Long,Short>>() {
private final TLongShortIterator it = _map.iterator();
public Map.Entry<Long,Short> next() {
it.advance();
long ik = it.key();
final Long key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Long,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Long getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Long,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Long key = ( ( Map.Entry<Long,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Long, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TLongShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Long && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Long, ? extends Short> map ) {
Iterator<? extends Entry<? extends Long,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Long,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Long wrapKey( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected long unwrapKey( Object key ) {
return ( ( Long ) key ).longValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TLongShortHashMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectByteMap;
import gnu.trove.iterator.TObjectByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectByteMapDecorator<K> extends AbstractMap<K, Byte>
implements Map<K, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectByteMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectByteMap</tt> to wrap.
*/
public TObjectByteMapDecorator( TObjectByteMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectByteMap</tt> instance.
*/
public TObjectByteMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Byte</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Byte put( K key, Byte value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
byte v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Byte remove( Object key ) {
byte v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Byte>> entrySet() {
return new AbstractSet<Map.Entry<K,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectByteMapDecorator.this.containsKey( k ) &&
TObjectByteMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Byte>> iterator() {
return new Iterator<Map.Entry<K,Byte>>() {
private final TObjectByteIterator<K> it = _map.iterator();
public Map.Entry<K,Byte> next() {
it.advance();
final K key = it.key();
final Byte v = wrapValue( it.value() );
return new Map.Entry<K,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Byte> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Byte>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Byte> map ) {
Iterator<? extends Entry<? extends K,? extends Byte>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectByteMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectByteMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectCharMap;
import gnu.trove.iterator.TObjectCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectCharMapDecorator<K> extends AbstractMap<K, Character>
implements Map<K, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectCharMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectCharMap</tt> to wrap.
*/
public TObjectCharMapDecorator( TObjectCharMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectCharMap</tt> instance.
*/
public TObjectCharMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Character</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Character put( K key, Character value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
char v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Character remove( Object key ) {
char v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Character>> entrySet() {
return new AbstractSet<Map.Entry<K,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectCharMapDecorator.this.containsKey( k ) &&
TObjectCharMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Character>> iterator() {
return new Iterator<Map.Entry<K,Character>>() {
private final TObjectCharIterator<K> it = _map.iterator();
public Map.Entry<K,Character> next() {
it.advance();
final K key = it.key();
final Character v = wrapValue( it.value() );
return new Map.Entry<K,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Character> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Character>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Character> map ) {
Iterator<? extends Entry<? extends K,? extends Character>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectCharMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectCharMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectDoubleMap;
import gnu.trove.iterator.TObjectDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectDoubleMapDecorator<K> extends AbstractMap<K, Double>
implements Map<K, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectDoubleMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectDoubleMap</tt> to wrap.
*/
public TObjectDoubleMapDecorator( TObjectDoubleMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectDoubleMap</tt> instance.
*/
public TObjectDoubleMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Double</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Double put( K key, Double value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
double v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Double remove( Object key ) {
double v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Double>> entrySet() {
return new AbstractSet<Map.Entry<K,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectDoubleMapDecorator.this.containsKey( k ) &&
TObjectDoubleMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Double>> iterator() {
return new Iterator<Map.Entry<K,Double>>() {
private final TObjectDoubleIterator<K> it = _map.iterator();
public Map.Entry<K,Double> next() {
it.advance();
final K key = it.key();
final Double v = wrapValue( it.value() );
return new Map.Entry<K,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Double> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Double>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Double> map ) {
Iterator<? extends Entry<? extends K,? extends Double>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectDoubleMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectDoubleMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectFloatMap;
import gnu.trove.iterator.TObjectFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectFloatMapDecorator<K> extends AbstractMap<K, Float>
implements Map<K, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectFloatMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectFloatMap</tt> to wrap.
*/
public TObjectFloatMapDecorator( TObjectFloatMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectFloatMap</tt> instance.
*/
public TObjectFloatMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Float</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Float put( K key, Float value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
float v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Float remove( Object key ) {
float v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Float>> entrySet() {
return new AbstractSet<Map.Entry<K,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectFloatMapDecorator.this.containsKey( k ) &&
TObjectFloatMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Float>> iterator() {
return new Iterator<Map.Entry<K,Float>>() {
private final TObjectFloatIterator<K> it = _map.iterator();
public Map.Entry<K,Float> next() {
it.advance();
final K key = it.key();
final Float v = wrapValue( it.value() );
return new Map.Entry<K,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Float> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Float>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Float> map ) {
Iterator<? extends Entry<? extends K,? extends Float>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectFloatMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectFloatMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectIntMap;
import gnu.trove.iterator.TObjectIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectIntMapDecorator<K> extends AbstractMap<K, Integer>
implements Map<K, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectIntMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectIntMap</tt> to wrap.
*/
public TObjectIntMapDecorator( TObjectIntMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectIntMap</tt> instance.
*/
public TObjectIntMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Integer</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( K key, Integer value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
int v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Integer remove( Object key ) {
int v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Integer>> entrySet() {
return new AbstractSet<Map.Entry<K,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectIntMapDecorator.this.containsKey( k ) &&
TObjectIntMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Integer>> iterator() {
return new Iterator<Map.Entry<K,Integer>>() {
private final TObjectIntIterator<K> it = _map.iterator();
public Map.Entry<K,Integer> next() {
it.advance();
final K key = it.key();
final Integer v = wrapValue( it.value() );
return new Map.Entry<K,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Integer> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Integer>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Integer> map ) {
Iterator<? extends Entry<? extends K,? extends Integer>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectIntMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectIntMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectLongMap;
import gnu.trove.iterator.TObjectLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectLongMapDecorator<K> extends AbstractMap<K, Long>
implements Map<K, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectLongMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectLongMap</tt> to wrap.
*/
public TObjectLongMapDecorator( TObjectLongMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectLongMap</tt> instance.
*/
public TObjectLongMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Long</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Long put( K key, Long value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
long v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Long remove( Object key ) {
long v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Long>> entrySet() {
return new AbstractSet<Map.Entry<K,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectLongMapDecorator.this.containsKey( k ) &&
TObjectLongMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Long>> iterator() {
return new Iterator<Map.Entry<K,Long>>() {
private final TObjectLongIterator<K> it = _map.iterator();
public Map.Entry<K,Long> next() {
it.advance();
final K key = it.key();
final Long v = wrapValue( it.value() );
return new Map.Entry<K,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Long> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Long>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Long> map ) {
Iterator<? extends Entry<? extends K,? extends Long>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectLongMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectLongMapDecorator

View File

@ -0,0 +1,352 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TObjectShortMap;
import gnu.trove.iterator.TObjectShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TObjectShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TObjectShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TObjectShortMapDecorator<K> extends AbstractMap<K, Short>
implements Map<K, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/**
* the wrapped primitive map
*/
protected TObjectShortMap<K> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TObjectShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TObjectShortMap</tt> to wrap.
*/
public TObjectShortMapDecorator( TObjectShortMap<K> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TObjectShortMap</tt> instance.
*/
public TObjectShortMap<K> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Short</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Short put( K key, Short value ) {
if ( value == null ) return wrapValue( _map.put( key, _map.getNoEntryValue() ) );
return wrapValue( _map.put( key, unwrapValue( value ) ) );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
short v = _map.get( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public Short remove( Object key ) {
short v = _map.remove( key );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<K,Short>> entrySet() {
return new AbstractSet<Map.Entry<K,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TObjectShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TObjectShortMapDecorator.this.containsKey( k ) &&
TObjectShortMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<K,Short>> iterator() {
return new Iterator<Map.Entry<K,Short>>() {
private final TObjectShortIterator<K> it = _map.iterator();
public Map.Entry<K,Short> next() {
it.advance();
final K key = it.key();
final Short v = wrapValue( it.value() );
return new Map.Entry<K,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry &&
( ( Map.Entry ) o ).getKey().equals( key ) &&
( ( Map.Entry ) o ).getValue().equals( val );
}
public K getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<K,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
K key = ( ( Map.Entry<K,Short> ) o ).getKey();
_map.remove( key );
modified = true;
}
return modified;
}
public boolean addAll(Collection<? extends Map.Entry<K,Short>> c) {
throw new UnsupportedOperationException();
}
public void clear() {
TObjectShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
return _map.containsKey( key );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return this._map.size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends K, ? extends Short> map ) {
Iterator<? extends Entry<? extends K,? extends Short>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends K,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal(ObjectInput in)
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TObjectShortMap<K> ) in.readObject();
}
// Implements Externalizable
public void writeExternal(ObjectOutput out) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TObjectShortMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortByteMap;
import gnu.trove.iterator.TShortByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortByteMapDecorator extends AbstractMap<Short, Byte>
implements Map<Short, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortByteMap</tt> to wrap.
*/
public TShortByteMapDecorator( TShortByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortByteMap</tt> instance.
*/
public TShortByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Short key, Byte value ) {
short k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Short,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortByteMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortByteMapDecorator.this.containsKey(k)
&& TShortByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Byte>> iterator() {
return new Iterator<Map.Entry<Short,Byte>>() {
private final TShortByteIterator it = _map.iterator();
public Map.Entry<Short,Byte> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Byte>() {
private Byte val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Byte> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Short,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortByteHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortCharMap;
import gnu.trove.iterator.TShortCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortCharMapDecorator extends AbstractMap<Short, Character>
implements Map<Short, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortCharMap</tt> to wrap.
*/
public TShortCharMapDecorator( TShortCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortCharMap</tt> instance.
*/
public TShortCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Short key, Character value ) {
short k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Character>> entrySet() {
return new AbstractSet<Map.Entry<Short,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortCharMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortCharMapDecorator.this.containsKey(k)
&& TShortCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Character>> iterator() {
return new Iterator<Map.Entry<Short,Character>>() {
private final TShortCharIterator it = _map.iterator();
public Map.Entry<Short,Character> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Character>() {
private Character val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Character> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Character> map ) {
Iterator<? extends Entry<? extends Short,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortCharHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortDoubleMap;
import gnu.trove.iterator.TShortDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortDoubleMapDecorator extends AbstractMap<Short, Double>
implements Map<Short, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortDoubleMap</tt> to wrap.
*/
public TShortDoubleMapDecorator( TShortDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortDoubleMap</tt> instance.
*/
public TShortDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Short key, Double value ) {
short k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Double>> entrySet() {
return new AbstractSet<Map.Entry<Short,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortDoubleMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortDoubleMapDecorator.this.containsKey(k)
&& TShortDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Double>> iterator() {
return new Iterator<Map.Entry<Short,Double>>() {
private final TShortDoubleIterator it = _map.iterator();
public Map.Entry<Short,Double> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Double>() {
private Double val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Double> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Double> map ) {
Iterator<? extends Entry<? extends Short,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortDoubleHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortFloatMap;
import gnu.trove.iterator.TShortFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortFloatMapDecorator extends AbstractMap<Short, Float>
implements Map<Short, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortFloatMap</tt> to wrap.
*/
public TShortFloatMapDecorator( TShortFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortFloatMap</tt> instance.
*/
public TShortFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Short key, Float value ) {
short k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Float>> entrySet() {
return new AbstractSet<Map.Entry<Short,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortFloatMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortFloatMapDecorator.this.containsKey(k)
&& TShortFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Float>> iterator() {
return new Iterator<Map.Entry<Short,Float>>() {
private final TShortFloatIterator it = _map.iterator();
public Map.Entry<Short,Float> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Float>() {
private Float val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Float> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Float> map ) {
Iterator<? extends Entry<? extends Short,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortFloatHashMapDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortIntMap;
import gnu.trove.iterator.TShortIntIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortIntMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortIntMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortIntMapDecorator extends AbstractMap<Short, Integer>
implements Map<Short, Integer>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortIntMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortIntMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortIntMap</tt> to wrap.
*/
public TShortIntMapDecorator( TShortIntMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortIntMap</tt> instance.
*/
public TShortIntMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Integer(0) if none was found.
*/
public Integer put( Short key, Integer value ) {
short k;
int v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
int retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Integer get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Integer remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
int v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Integer>> entrySet() {
return new AbstractSet<Map.Entry<Short,Integer>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortIntMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortIntMapDecorator.this.containsKey(k)
&& TShortIntMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Integer>> iterator() {
return new Iterator<Map.Entry<Short,Integer>>() {
private final TShortIntIterator it = _map.iterator();
public Map.Entry<Short,Integer> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
int iv = it.value();
final Integer v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Integer>() {
private Integer val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Integer getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Integer setValue( Integer value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Integer> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Integer> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Integer>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortIntMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Integer && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Integer> map ) {
Iterator<? extends Entry<? extends Short,? extends Integer>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Integer> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Integer wrapValue( int k ) {
return Integer.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected int unwrapValue( Object value ) {
return ( ( Integer ) value ).intValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortIntMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortIntHashMapDecorator

View File

@ -0,0 +1,141 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.list.TShortList;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.AbstractList;
import java.util.List;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortList conform to the <tt>java.util.List</tt> API.
* This class simply decorates an underlying TShortList and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
*
* @author Robert D. Eden
*/
public class TShortListDecorator extends AbstractList<Short>
implements List<Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive list */
protected TShortList list;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortListDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param list the <tt>TShortList</tt> to wrap.
*/
public TShortListDecorator( TShortList list ) {
super();
this.list = list;
}
/**
* Returns a reference to the list wrapped by this decorator.
*
* @return the wrapped <tt>TShortList</tt> instance.
*/
public TShortList getList() {
return list;
}
@Override
public int size() {
return list.size();
}
@Override
public Short get( int index ) {
short value = list.get( index );
if ( value == list.getNoEntryValue() ) return null;
else return Short.valueOf( value );
}
@Override
public Short set( int index, Short value ) {
short previous_value = list.set( index, value );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Short.valueOf( previous_value );
}
@Override
public void add( int index, Short value ) {
list.insert( index, value.shortValue() );
}
@Override
public Short remove( int index ) {
short previous_value = list.removeAt( index );
if ( previous_value == list.getNoEntryValue() ) return null;
else return Short.valueOf( previous_value );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// LIST
list = ( TShortList ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// LIST
out.writeObject( list );
}
}

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortLongMap;
import gnu.trove.iterator.TShortLongIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortLongMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortLongMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortLongMapDecorator extends AbstractMap<Short, Long>
implements Map<Short, Long>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortLongMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortLongMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortLongMap</tt> to wrap.
*/
public TShortLongMapDecorator( TShortLongMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortLongMap</tt> instance.
*/
public TShortLongMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Long(0) if none was found.
*/
public Long put( Short key, Long value ) {
short k;
long v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
long retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Long get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Long remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
long v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Long>> entrySet() {
return new AbstractSet<Map.Entry<Short,Long>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortLongMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortLongMapDecorator.this.containsKey(k)
&& TShortLongMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Long>> iterator() {
return new Iterator<Map.Entry<Short,Long>>() {
private final TShortLongIterator it = _map.iterator();
public Map.Entry<Short,Long> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
long iv = it.value();
final Long v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Long>() {
private Long val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Long getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Long setValue( Long value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Long> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Long> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Long>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortLongMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Long && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Long> map ) {
Iterator<? extends Entry<? extends Short,? extends Long>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Long> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Long wrapValue( long k ) {
return Long.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected long unwrapValue( Object value ) {
return ( ( Long ) value ).longValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortLongMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortLongHashMapDecorator

View File

@ -0,0 +1,361 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortObjectMap;
import gnu.trove.iterator.TShortObjectIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortObjectMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortObjectMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortObjectMapDecorator<V> extends AbstractMap<Short, V>
implements Map<Short, V>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortObjectMap<V> _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortObjectMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortObjectMap</tt> to wrap.
*/
public TShortObjectMapDecorator( TShortObjectMap<V> map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortObjectMap</tt> instance.
*/
public TShortObjectMap<V> getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Short</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or <tt>null</tt> if none was found.
*/
public V put( Short key, V value ) {
short k;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
return _map.put( k, value );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public V get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( ( Short ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.get( k );
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or Integer(0) if it was not found in the map
*/
public V remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( ( Short ) key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
return _map.remove( k );
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,V>> entrySet() {
return new AbstractSet<Map.Entry<Short,V>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortObjectMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if ( o instanceof Map.Entry ) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortObjectMapDecorator.this.containsKey( k ) &&
TShortObjectMapDecorator.this.get( k ).equals( v );
} else {
return false;
}
}
public Iterator<Map.Entry<Short,V>> iterator() {
return new Iterator<Map.Entry<Short,V>>() {
private final TShortObjectIterator<V> it = _map.iterator();
public Map.Entry<Short,V> next() {
it.advance();
short k = it.key();
final Short key = (k == _map.getNoEntryKey()) ? null : wrapKey( k );
final V v = it.value();
return new Map.Entry<Short,V>() {
private V val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals( key )
&& ( ( Map.Entry ) o ).getValue().equals( val );
}
public Short getKey() {
return key;
}
public V getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public V setValue( V value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,V> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,V> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short,V>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortObjectMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return _map.containsValue( val );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( ( ( Short ) key ).shortValue() );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends V> map ) {
Iterator<? extends Entry<? extends Short,? extends V>> it = map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends V> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Short key ) {
return key.shortValue();
}
// Implements Externalizable
@SuppressWarnings("unchecked")
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
//noinspection unchecked
_map = ( TShortObjectMap<V> ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// MAP
out.writeObject( _map );
}
} // TShortObjectHashMapDecorator

View File

@ -0,0 +1,230 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.set.TShortSet;
import gnu.trove.iterator.TShortIterator;
import java.io.*;
import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Set;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortSet conform to the <tt>java.util.Set</tt> API.
* This class simply decorates an underlying TShortSet and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* </p>
* <p/>
* Created: Tue Sep 24 22:08:17 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortSetDecorator extends AbstractSet<Short>
implements Set<Short>, Externalizable {
static final long serialVersionUID = 1L;
/** the wrapped primitive set */
protected TShortSet _set;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortSetDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive set.
*
* @param set the <tt>TShortSet</tt> to wrap.
*/
public TShortSetDecorator( TShortSet set ) {
super();
this._set = set;
}
/**
* Returns a reference to the set wrapped by this decorator.
*
* @return the wrapped <tt>TShortSet</tt> instance.
*/
public TShortSet getSet() {
return _set;
}
/**
* Inserts a value into the set.
*
* @param value true if the set was modified by the insertion
*/
public boolean add( Short value ) {
return value != null && _set.add( value.shortValue() );
}
/**
* Compares this set with another set for equality of their stored
* entries.
*
* @param other an <code>Object</code> value
* @return true if the sets are identical
*/
public boolean equals( Object other ) {
if ( _set.equals( other ) ) {
return true; // comparing two trove sets
} else if ( other instanceof Set ) {
Set<?> that = ( Set<?> ) other;
if ( that.size() != _set.size() ) {
return false; // different sizes, no need to compare
} else { // now we have to do it the hard way
Iterator<?> it = that.iterator();
for ( int i = that.size(); i-- > 0; ) {
Object val = it.next();
if ( val instanceof Short ) {
short v = ( ( Short ) val ).shortValue();
if ( _set.contains( v ) ) {
// match, ok to continue
} else {
return false; // no match: we're done
}
} else {
return false; // different type in other set
}
}
return true; // all entries match
}
} else {
return false;
}
}
/**
* Empties the set.
*/
public void clear() {
this._set.clear();
}
/**
* Deletes a value from the set.
*
* @param value an <code>Object</code> value
* @return true if the set was modified
*/
public boolean remove( Object value ) {
return value instanceof Short && _set.remove( ( ( Short ) value ).shortValue() );
}
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Short> iterator() {
return new Iterator<Short>() {
private final TShortIterator it = _set.iterator();
public Short next() {
return Short.valueOf( it.next() );
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
/**
* Returns the number of entries in the set.
*
* @return the set's size.
*/
public int size() {
return this._set.size();
}
/**
* Indicates whether set has any entries.
*
* @return true if the set is empty
*/
public boolean isEmpty() {
return this._set.size() == 0;
}
/**
* {@inheritDoc}
*/
@Override
public boolean contains( Object o ) {
if ( ! ( o instanceof Short ) ) return false;
return _set.contains( ( ( Short ) o ).shortValue() );
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// SET
_set = ( TShortSet ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte( 0 );
// SET
out.writeObject( _set );
}
} // TShortHashSetDecorator

View File

@ -0,0 +1,409 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TShortShortMap;
import gnu.trove.iterator.TShortShortIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TShortShortMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TShortShortMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TShortShortMapDecorator extends AbstractMap<Short, Short>
implements Map<Short, Short>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TShortShortMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TShortShortMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TShortShortMap</tt> to wrap.
*/
public TShortShortMapDecorator( TShortShortMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TShortShortMap</tt> instance.
*/
public TShortShortMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Short(0) if none was found.
*/
public Short put( Short key, Short value ) {
short k;
short v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
short retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Short get( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Short remove( Object key ) {
short k;
if ( key != null ) {
if ( key instanceof Short ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
short v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Short,Short>> entrySet() {
return new AbstractSet<Map.Entry<Short,Short>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TShortShortMapDecorator.this.isEmpty();
}
@SuppressWarnings("rawtypes")
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TShortShortMapDecorator.this.containsKey(k)
&& TShortShortMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Short,Short>> iterator() {
return new Iterator<Map.Entry<Short,Short>>() {
private final TShortShortIterator it = _map.iterator();
public Map.Entry<Short,Short> next() {
it.advance();
short ik = it.key();
final Short key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
short iv = it.value();
final Short v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Short,Short>() {
private Short val = v;
@SuppressWarnings("rawtypes")
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Short getKey() {
return key;
}
public Short getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Short setValue( Short value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Short,Short> o ) {
throw new UnsupportedOperationException();
}
@SuppressWarnings("unchecked")
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Short key = ( ( Map.Entry<Short,Short> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Short, Short>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TShortShortMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Short && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Short && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Short, ? extends Short> map ) {
Iterator<? extends Entry<? extends Short,? extends Short>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Short,? extends Short> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Short wrapKey( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected short unwrapKey( Object key ) {
return ( ( Short ) key ).shortValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Short wrapValue( short k ) {
return Short.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected short unwrapValue( Object value ) {
return ( ( Short ) value ).shortValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TShortShortMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TShortShortHashMapDecorator

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Interface for functions that accept and return one byte primitive.
*/
public interface TByteFunction {
/**
* Execute this function with <tt>value</tt>
*
* @param value a <code>byte</code> input
* @return a <code>byte</code> result
*/
public byte execute( byte value );
}

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Interface for functions that accept and return one char primitive.
*/
public interface TCharFunction {
/**
* Execute this function with <tt>value</tt>
*
* @param value a <code>char</code> input
* @return a <code>char</code> result
*/
public char execute( char value );
}

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Interface for functions that accept and return one double primitive.
*/
public interface TDoubleFunction {
/**
* Execute this function with <tt>value</tt>
*
* @param value a <code>double</code> input
* @return a <code>double</code> result
*/
public double execute( double value );
}

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Interface for functions that accept and return one float primitive.
*/
public interface TFloatFunction {
/**
* Execute this function with <tt>value</tt>
*
* @param value a <code>float</code> input
* @return a <code>float</code> result
*/
public float execute( float value );
}

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Interface for functions that accept and return one int primitive.
*/
public interface TIntFunction {
/**
* Execute this function with <tt>value</tt>
*
* @param value a <code>int</code> input
* @return a <code>int</code> result
*/
public int execute( int value );
}

View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Interface for functions that accept and return one long primitive.
*/
public interface TLongFunction {
/**
* Execute this function with <tt>value</tt>
*
* @param value a <code>long</code> input
* @return a <code>long</code> result
*/
public long execute( long value );
}

View File

@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.function;
/**
* Interface for functions that accept and return one Object reference.
* <p/>
* Created: Mon Nov 5 22:19:36 2001
*
* @author Eric D. Friedman
* @version $Id: TObjectFunction.java,v 1.1.2.1 2009/09/06 17:02:19 upholderoftruth Exp $
*/
public interface TObjectFunction<T, R> {
/**
* Execute this function with <tt>value</tt>
*
* @param value an <code>Object</code> input
* @return an <code>Object</code> result
*/
public R execute( T value );
}// TObjectFunction

Some files were not shown because too many files have changed in this diff Show More