AbstractDouble2IntFunction.java :  » Natural-Language-Processing » Stanford-CoreNLP » it » unimi » dsi » fastutil » doubles » Java Open Source

Java Open Source » Natural Language Processing » Stanford CoreNLP 
Stanford CoreNLP » it » unimi » dsi » fastutil » doubles » AbstractDouble2IntFunction.java


/* Generic definitions */




/* Assertions (useful to generate conditional code) */
/* Current type and class (and size, if applicable) */
/* Value methods */
/* Interfaces (keys) */
/* Interfaces (values) */
/* Abstract implementations (keys) */
/* Abstract implementations (values) */
/* Static containers (keys) */
/* Static containers (values) */
/* Implementations */
/* Synchronized wrappers */
/* Unmodifiable wrappers */
/* Other wrappers */
/* Methods (keys) */
/* Methods (values) */
/* Methods (keys/values) */
/* Methods that have special names depending on keys (but the special names depend on values) */
/* Equality */
/* Object/Reference-only definitions (keys) */
/* Primitive-type-only definitions (keys) */
/* Object/Reference-only definitions (values) */
/* Primitive-type-only definitions (values) */
/*     
 * fastutil: Fast & compact type-specific collections for Java
 *
 * Copyright (C) 2002-2008 Sebastiano Vigna 
 *
 *  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
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
package it.unimi.dsi.fastutil.doubles;
/** An abstract class providing basic methods for functions implementing a type-specific interface.
 *
 * <P>Optional operations just throw an {@link
 * UnsupportedOperationException}. Generic versions of accessors delegate to
 * the corresponding type-specific counterparts following the interface rules
 * (they take care of returning <code>null</code> on a missing key).
 *
 * <P>This class handles directly a default return
 * value (including {@linkplain #defaultReturnValue() methods to access
 * it}). Instances of classes inheriting from this class have just to return
 * <code>defRetValue</code> to denote lack of a key in type-specific methods. The value
 * is serialized.
 *
 * <P>Implementing subclasses have just to provide type-specific <code>get()</code>,
 * type-specific <code>containsKey()</code>, and <code>size()</cose> methods.
 *
 */
public abstract class AbstractDouble2IntFunction implements Double2IntFunction , java.io.Serializable {
 protected AbstractDouble2IntFunction() {}
 /**
   * The default return value for <code>get()</code>, <code>put()</code> and
   * <code>remove()</code>.  
   */
 protected int defRetValue;
 public void defaultReturnValue( final int rv ) {
  defRetValue = rv;
 }
 public int defaultReturnValue() {
  return defRetValue;
 }
 public int put( double key, int value ) {
  throw new UnsupportedOperationException();
 }
 public int remove( double key ) {
  throw new UnsupportedOperationException();
 }
 public void clear() {
  throw new UnsupportedOperationException();
 }
 public boolean containsKey( final Object ok ) {
  return containsKey( ((((Double)(ok)).doubleValue())) );
 }
 /** Delegates to the corresponding type-specific method, taking care of returning <code>null</code> on a missing key.
   *
   * <P>This method must check whether the provided key is in the map using <code>containsKey()</code>. Thus,
   * it probes the map <em>twice</em>. Implementors of subclasses should override it with a more efficient method.
   */
 public Integer get( final Object ok ) {
  final double k = ((((Double)(ok)).doubleValue()));
  return containsKey( k ) ? (Integer.valueOf(get( k ))) : null;
 }
 /** Delegates to the corresponding type-specific method, taking care of returning <code>null</code> on a missing key. 
   *
   * <P>This method must check whether the provided key is in the map using <code>containsKey()</code>. Thus,
   * it probes the map <em>twice</em>. Implementors of subclasses should override it with a more efficient method.
   */
 public Integer put( final Double ok, final Integer ov ) {
  final double k = ((ok).doubleValue());
  final int v = put( k, ((ov).intValue()) );
  return containsKey( k ) ? (Integer.valueOf(v)) : null;
 }
 /** Delegates to the corresponding type-specific method, taking care of returning <code>null</code> on a missing key. 
   *
   * <P>This method must check whether the provided key is in the map using <code>containsKey()</code>. Thus,
   * it probes the map <em>twice</em>. Implementors of subclasses should override it with a more efficient method.
   */
 public Integer remove( final Object ok ) {
  final double k = ((((Double)(ok)).doubleValue()));
  final int v = remove( k );
  return containsKey( k ) ? (Integer.valueOf(v)) : null;
 }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.