Html程序  |  619行  |  36.32 KB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:59 PST 2010 -->
<TITLE>
MapMaker (Guava Libraries 2010.01.04)
</TITLE>

<META NAME="date" CONTENT="2010-01-04">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

<SCRIPT type="text/javascript">
function windowTitle()
{
    if (location.href.indexOf('is-external=true') == -1) {
        parent.document.title="MapMaker (Guava Libraries 2010.01.04)";
    }
}
</SCRIPT>
<NOSCRIPT>
</NOSCRIPT>

</HEAD>

<BODY BGCOLOR="white" onload="windowTitle();">
<HR>


<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/MapMaker.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/google/common/collect/MapDifference.ValueDifference.html" title="interface in com.google.common.collect"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/google/common/collect/Maps.html" title="class in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?com/google/common/collect/MapMaker.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="MapMaker.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<!-- ========= END OF TOP NAVBAR ========= -->

<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
com.google.common.collect</FONT>
<BR>
Class MapMaker</H2>
<PRE>
<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A>
  <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.collect.MapMaker</B>
</PRE>
<HR>
<DL>
<DT><PRE>public final class <B>MapMaker</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL>
</PRE>

<P>
A <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ConcurrentMap</CODE></A> builder, providing any combination of these
 features: <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref">soft</A> or <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref">weak</A> keys, soft or weak values, timed expiration, and on-demand
 computation of values. Usage example: <pre> <code>ConcurrentMap&lt;Key, Graph&gt; graphs = new MapMaker()
       .concurrencyLevel(32)
       .softKeys()
       .weakValues()
       .expiration(30, TimeUnit.MINUTES)
       .makeComputingMap(
           new Function&lt;Key, Graph&gt;() {
             public Graph apply(Key key) {
               return createExpensiveGraph(key);
             }
           });</code></pre>

 These features are all optional; <code>new MapMaker().makeMap()</code>
 returns a valid concurrent map that behaves exactly like a
 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ConcurrentHashMap</CODE></A>.

 The returned map is implemented as a hash table with similar performance
 characteristics to <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentHashMap.html?is-external=true" title="class or interface in java.util.concurrent"><CODE>ConcurrentHashMap</CODE></A>. It supports all optional
 operations of the <code>ConcurrentMap</code> interface. It does not permit
 null keys or values. It is serializable; however, serializing a map that
 uses soft or weak references can give unpredictable results.

 <p><b>Note:</b> by default, the returned map uses equality comparisons
 (the <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>equals</CODE></A> method) to determine equality
 for keys or values. However, if <A HREF="../../../../com/google/common/collect/MapMaker.html#weakKeys()"><CODE>weakKeys()</CODE></A> or <A HREF="../../../../com/google/common/collect/MapMaker.html#softKeys()"><CODE>softKeys()</CODE></A> was specified, the map uses identity (<code>==</code>)
 comparisons instead for keys. Likewise, if <A HREF="../../../../com/google/common/collect/MapMaker.html#weakValues()"><CODE>weakValues()</CODE></A> or
 <A HREF="../../../../com/google/common/collect/MapMaker.html#softValues()"><CODE>softValues()</CODE></A> was specified, the map uses identity comparisons
 for values.

 <p>The returned map has <i>weakly consistent iteration</i>: an iterator
 over one of the map's view collections may reflect some, all or none of
 the changes made to the map after the iterator was created.

 <p>An entry whose key or value is reclaimed by the garbage collector
 immediately disappears from the map. (If the default settings of strong
 keys and strong values are used, this will never happen.) The client can
 never observe a partially-reclaimed entry. Any <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.Entry.html?is-external=true" title="class or interface in java.util"><CODE>Map.Entry</CODE></A>
 instance retrieved from the map's <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true#entrySet()" title="class or interface in java.util">entry set</A>
 is snapshot of that entry's state at the time of retrieval.

 <p><code>new MapMaker().weakKeys().makeMap()</code> can almost always be
 used as a drop-in replacement for <A HREF="http://java.sun.com/javase/6/docs/api/java/util/WeakHashMap.html?is-external=true" title="class or interface in java.util"><CODE>WeakHashMap</CODE></A>, adding
 concurrency, asynchronous cleanup, identity-based equality for keys, and
 great flexibility.
<P>

<P>
<DL>
<DT><B>Since:</B></DT>
  <DD>2010.01.04 <b>stable</b> (imported from Google Collections Library)</DD>
<DT><B>Author:</B></DT>
  <DD>Bob Lee, Kevin Bourrillion</DD>
</DL>
<HR>

<P>

<!-- ======== CONSTRUCTOR SUMMARY ======== -->

<A NAME="constructor_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#MapMaker()">MapMaker</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Constructs a new <code>MapMaker</code> instance with default settings,
 including strong keys, strong values, and no automatic expiration.</TD>
</TR>
</TABLE>
&nbsp;
<!-- ========== METHOD SUMMARY =========== -->

<A NAME="method_summary"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2">
<B>Method Summary</B></FONT></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#concurrencyLevel(int)">concurrencyLevel</A></B>(int&nbsp;concurrencyLevel)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Guides the allowed concurrency among update operations.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#expiration(long, java.util.concurrent.TimeUnit)">expiration</A></B>(long&nbsp;duration,
           <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;unit)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifies that each entry should be automatically removed from the
 map once a fixed duration has passed since the entry's creation.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#initialCapacity(int)">initialCapacity</A></B>(int&nbsp;initialCapacity)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sets a custom initial capacity (defaults to 16).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY="">
<TR ALIGN="right" VALIGN="">
<TD NOWRAP><FONT SIZE="-1">
<CODE>&lt;K,V&gt; <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true" title="class or interface in java.util.concurrent">ConcurrentMap</A>&lt;K,V&gt;</CODE></FONT></TD>
</TR>
</TABLE>
</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#makeComputingMap(com.google.common.base.Function)">makeComputingMap</A></B>(<A HREF="../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A>&lt;? super K,? extends V&gt;&nbsp;computingFunction)</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Builds a map that supports atomic, on-demand computation of values.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY="">
<TR ALIGN="right" VALIGN="">
<TD NOWRAP><FONT SIZE="-1">
<CODE>&lt;K,V&gt; <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true" title="class or interface in java.util.concurrent">ConcurrentMap</A>&lt;K,V&gt;</CODE></FONT></TD>
</TR>
</TABLE>
</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#makeMap()">makeMap</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Builds the final map, without on-demand computation of values.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#softKeys()">softKeys</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifies that each key (not value) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>SoftReference</CODE></A> (by default, strong references
 are used).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#softValues()">softValues</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifies that each value (not key) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>SoftReference</CODE></A> (by default, strong references
 are used).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#weakKeys()">weakKeys</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifies that each key (not value) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>WeakReference</CODE></A> (by default, strong references
 are used).</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>&nbsp;<A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A></CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../../com/google/common/collect/MapMaker.html#weakValues()">weakValues</A></B>()</CODE>

<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Specifies that each value (not key) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>WeakReference</CODE></A> (by default, strong references
 are used).</TD>
</TR>
</TABLE>
&nbsp;<A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor">
<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD>
</TR>
</TABLE>
&nbsp;
<P>

<!-- ========= CONSTRUCTOR DETAIL ======== -->

<A NAME="constructor_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="MapMaker()"><!-- --></A><H3>
MapMaker</H3>
<PRE>
public <B>MapMaker</B>()</PRE>
<DL>
<DD>Constructs a new <code>MapMaker</code> instance with default settings,
 including strong keys, strong values, and no automatic expiration.
<P>
</DL>

<!-- ============ METHOD DETAIL ========== -->

<A NAME="method_detail"><!-- --></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2">
<B>Method Detail</B></FONT></TH>
</TR>
</TABLE>

<A NAME="initialCapacity(int)"><!-- --></A><H3>
initialCapacity</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>initialCapacity</B>(int&nbsp;initialCapacity)</PRE>
<DL>
<DD>Sets a custom initial capacity (defaults to 16). Resizing this or
 any other kind of hash table is a relatively slow operation, so,
 when possible, it is a good idea to provide estimates of expected
 table sizes.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>initialCapacity</code> is
   negative
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if an initial capacity was already set</DL>
</DD>
</DL>
<HR>

<A NAME="concurrencyLevel(int)"><!-- --></A><H3>
concurrencyLevel</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>concurrencyLevel</B>(int&nbsp;concurrencyLevel)</PRE>
<DL>
<DD>Guides the allowed concurrency among update operations. Used as a
 hint for internal sizing. The table is internally partitioned to try
 to permit the indicated number of concurrent updates without
 contention.  Because placement in hash tables is essentially random,
 the actual concurrency will vary. Ideally, you should choose a value
 to accommodate as many threads as will ever concurrently modify the
 table. Using a significantly higher value than you need can waste
 space and time, and a significantly lower value can lead to thread
 contention. But overestimates and underestimates within an order of
 magnitude do not usually have much noticeable impact. A value of one
 is appropriate when it is known that only one thread will modify and
 all others will only read. Defaults to 16.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>concurrencyLevel</code> is
     nonpositive
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if a concurrency level was already set</DL>
</DD>
</DL>
<HR>

<A NAME="weakKeys()"><!-- --></A><H3>
weakKeys</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>weakKeys</B>()</PRE>
<DL>
<DD>Specifies that each key (not value) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>WeakReference</CODE></A> (by default, strong references
 are used).

 <p><b>Note:</b> the map will use identity (<code>==</code>) comparison
 to determine equality of weak keys, which may not behave as you expect.
 For example, storing a key in the map and then attempting a lookup
 using a different but <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>equals</CODE></A>-equivalent
 key will always fail.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the key strength was already set<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>WeakReference</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="softKeys()"><!-- --></A><H3>
softKeys</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>softKeys</B>()</PRE>
<DL>
<DD>Specifies that each key (not value) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>SoftReference</CODE></A> (by default, strong references
 are used).

 <p><b>Note:</b> the map will use identity (<code>==</code>) comparison
 to determine equality of soft keys, which may not behave as you expect.
 For example, storing a key in the map and then attempting a lookup
 using a different but <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>equals</CODE></A>-equivalent
 key will always fail.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the key strength was already set<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>SoftReference</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="weakValues()"><!-- --></A><H3>
weakValues</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>weakValues</B>()</PRE>
<DL>
<DD>Specifies that each value (not key) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>WeakReference</CODE></A> (by default, strong references
 are used).

 <p>Weak values will be garbage collected once they are weakly
 reachable. This makes them a poor candidate for caching; consider
 <A HREF="../../../../com/google/common/collect/MapMaker.html#softValues()"><CODE>softValues()</CODE></A> instead.

 <p><b>Note:</b> the map will use identity (<code>==</code>) comparison
 to determine equality of weak values. This will notably impact
 the behavior of <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true#containsValue(java.lang.Object)" title="class or interface in java.util"><CODE>containsValue</CODE></A>,
 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true#remove(java.lang.Object, java.lang.Object)" title="class or interface in java.util.concurrent"><CODE>remove(Object, Object)</CODE></A>,
 and <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true#replace(K, V, V)" title="class or interface in java.util.concurrent"><CODE>replace(K, V, V)</CODE></A>.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the key strength was already set<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/WeakReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>WeakReference</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="softValues()"><!-- --></A><H3>
softValues</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>softValues</B>()</PRE>
<DL>
<DD>Specifies that each value (not key) stored in the map should be
 wrapped in a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>SoftReference</CODE></A> (by default, strong references
 are used).

 <p>Soft values will be garbage collected in response to memory
 demand, and in a least-recently-used manner. This makes them a
 good candidate for caching.

 <p><b>Note:</b> the map will use identity (<code>==</code>) comparison
 to determine equality of soft values. This will notably impact
 the behavior of <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true#containsValue(java.lang.Object)" title="class or interface in java.util"><CODE>containsValue</CODE></A>,
 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true#remove(java.lang.Object, java.lang.Object)" title="class or interface in java.util.concurrent"><CODE>remove(Object, Object)</CODE></A>,
 and <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true#replace(K, V, V)" title="class or interface in java.util.concurrent"><CODE>replace(K, V, V)</CODE></A>.
<P>
<DD><DL>

<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the value strength was already set<DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/ref/SoftReference.html?is-external=true" title="class or interface in java.lang.ref"><CODE>SoftReference</CODE></A></DL>
</DD>
</DL>
<HR>

<A NAME="expiration(long, java.util.concurrent.TimeUnit)"><!-- --></A><H3>
expiration</H3>
<PRE>
public <A HREF="../../../../com/google/common/collect/MapMaker.html" title="class in com.google.common.collect">MapMaker</A> <B>expiration</B>(long&nbsp;duration,
                           <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/TimeUnit.html?is-external=true" title="class or interface in java.util.concurrent">TimeUnit</A>&nbsp;unit)</PRE>
<DL>
<DD>Specifies that each entry should be automatically removed from the
 map once a fixed duration has passed since the entry's creation.
<P>
<DD><DL>
<DT><B>Parameters:</B><DD><CODE>duration</CODE> - the length of time after an entry is created that it
     should be automatically removed<DD><CODE>unit</CODE> - the unit that <code>duration</code> is expressed in
<DT><B>Throws:</B>
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>duration</code> is not positive
<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the expiration time was already set</DL>
</DD>
</DL>
<HR>

<A NAME="makeMap()"><!-- --></A><H3>
makeMap</H3>
<PRE>
public &lt;K,V&gt; <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true" title="class or interface in java.util.concurrent">ConcurrentMap</A>&lt;K,V&gt; <B>makeMap</B>()</PRE>
<DL>
<DD>Builds the final map, without on-demand computation of values. This method
 does not alter the state of this <code>MapMaker</code> instance, so it can be
 invoked again to create multiple independent maps.
<P>
<DD><DL>
<DT><B>Type Parameters:</B><DD><CODE>K</CODE> - the type of keys to be stored in the returned map<DD><CODE>V</CODE> - the type of values to be stored in the returned map
<DT><B>Returns:</B><DD>a concurrent map having the requested features</DL>
</DD>
</DL>
<HR>

<A NAME="makeComputingMap(com.google.common.base.Function)"><!-- --></A><H3>
makeComputingMap</H3>
<PRE>
public &lt;K,V&gt; <A HREF="http://java.sun.com/javase/6/docs/api/java/util/concurrent/ConcurrentMap.html?is-external=true" title="class or interface in java.util.concurrent">ConcurrentMap</A>&lt;K,V&gt; <B>makeComputingMap</B>(<A HREF="../../../../com/google/common/base/Function.html" title="interface in com.google.common.base">Function</A>&lt;? super K,? extends V&gt;&nbsp;computingFunction)</PRE>
<DL>
<DD>Builds a map that supports atomic, on-demand computation of values. <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true#get(java.lang.Object)" title="class or interface in java.util"><CODE>Map.get(java.lang.Object)</CODE></A> either returns an already-computed value for the given key,
 atomically computes it using the supplied function, or, if another thread
 is currently computing the value for this key, simply waits for that thread
 to finish and returns its computed value. Note that the function may be
 executed concurrently by multiple threads, but only for distinct keys.

 <p>If an entry's value has not finished computing yet, query methods
 besides <code>get</code> return immediately as if an entry doesn't exist. In
 other words, an entry isn't externally visible until the value's
 computation completes.

 <p><A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true#get(java.lang.Object)" title="class or interface in java.util"><CODE>Map.get(java.lang.Object)</CODE></A> on the returned map will never return <code>null</code>. It
 may throw:

 <ul>
 <li><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang"><CODE>NullPointerException</CODE></A> if the key is null or the computing
     function returns null
 <li><A HREF="../../../../com/google/common/collect/ComputationException.html" title="class in com.google.common.collect"><CODE>ComputationException</CODE></A> if an exception was thrown by the
     computing function. If that exception is already of type <A HREF="../../../../com/google/common/collect/ComputationException.html" title="class in com.google.common.collect"><CODE>ComputationException</CODE></A>, it is propagated directly; otherwise it is
     wrapped.
 </ul>

 <p><b>Note:</b> Callers of <code>get</code> <i>must</i> ensure that the key
 argument is of type <code>K</code>. The <code>get</code> method accepts <code>Object</code>, so the key type is not checked at compile time. Passing an object
 of a type other than <code>K</code> can result in that object being unsafely
 passed to the computing function as type <code>K</code>, and unsafely stored in
 the map.

 <p>If <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Map.html?is-external=true#put(K, V)" title="class or interface in java.util"><CODE>Map.put(K, V)</CODE></A> is called before a computation completes, other
 threads waiting on the computation will wake up and return the stored
 value. When the computation completes, its new result will overwrite the
 value that was put in the map manually.

 <p>This method does not alter the state of this <code>MapMaker</code> instance,
 so it can be invoked again to create multiple independent maps.
<P>
<DD><DL>
</DL>
</DD>
</DL>
<!-- ========= END OF CLASS DATA ========= -->
<HR>


<!-- ======= START OF BOTTOM NAVBAR ====== -->
<A NAME="navbar_bottom"><!-- --></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_bottom_firstrow"><!-- --></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
  <TR ALIGN="center" VALIGN="top">
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/MapMaker.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
  </TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>

<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
&nbsp;<A HREF="../../../../com/google/common/collect/MapDifference.ValueDifference.html" title="interface in com.google.common.collect"><B>PREV CLASS</B></A>&nbsp;
&nbsp;<A HREF="../../../../com/google/common/collect/Maps.html" title="class in com.google.common.collect"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
  <A HREF="../../../../index.html?com/google/common/collect/MapMaker.html" target="_top"><B>FRAMES</B></A>  &nbsp;
&nbsp;<A HREF="MapMaker.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;
&nbsp;<SCRIPT type="text/javascript">
  <!--
  if(window==top) {
    document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>');
  }
  //-->
</SCRIPT>
<NOSCRIPT>
  <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>


</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL:&nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<!-- ======== END OF BOTTOM NAVBAR ======= -->

<HR>

</BODY>
</HTML>