it.unimi.dsi.util.StringMap Maven / Gradle / Ivy
Show all versions of dsi-utils Show documentation
package it.unimi.dsi.util;
/*
* DSI utilities
*
* Copyright (C) 2008-2009 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 program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
import it.unimi.dsi.fastutil.objects.Object2LongFunction;
import it.unimi.dsi.fastutil.objects.ObjectList;
import java.io.Serializable;
/** A map from strings to numbers (and possibly vice versa).
*
* String maps represent mappings from strings (actually, any subclass of {@link CharSequence})
* to numbers; they can support {@linkplain #list() reverse
* mapping}, too. The latter has usually sense only if the map is minimal and perfect (e.g., a bijection of a set
* of string with an initial segment of the natural numbers of the same size). String maps are useful for
* terms of an MG4J
* inverted index, URLs of a WebGraph-compressed
* web snapshot, and so on.
*
*
Warning: the return value of {@link #list()} is a fastutil
{@link ObjectList}.
* This in principle is not sensible, as string maps return longs (they extend
* {@link Object2LongFunction}), and {@link ObjectList} has only integer index
* support. At some point in the future, this problem will be addressed with a full-blown hierarchy
* of long lists (and corresponding iterators)
* in fastutil
.
*
* @author Sebastiano Vigna
* @since 0.2
*/
public interface StringMap extends Object2LongFunction, Serializable {
/** Returns a list view of the domain of this string map (optional operation).
*
* Note that the list view acts as an inverse of the mapping implemented by this map.
*
* @return a list view of the domain of this string map, or null
if this map does
* not support this operation.
*/
public ObjectList extends S> list();
}