BiMap (Guava: Google Core Libraries for Java 23.0 API)

文章推薦指數: 80 %
投票人數:10人

A bimap (or "bidirectional map") is a map that preserves the uniqueness of its values as well as that of its keys. This constraint enables bimaps to support ... Skipnavigationlinks Overview Package Class Use Tree Deprecated Index Help Prev Class Next Class Frames No Frames All Classes Summary:  Nested |  Field |  Constr |  Method Detail:  Field |  Constr |  Method AllSuperinterfaces: Map AllKnownImplementingClasses: EnumBiMap,EnumHashBiMap,HashBiMap,ImmutableBiMap @GwtCompatible publicinterfaceBiMap extendsMap Abimap(or"bidirectionalmap")isamapthatpreservestheuniquenessof itsvaluesaswellasthatofitskeys.Thisconstraintenablesbimapsto supportan"inverseview",whichisanotherbimapcontainingthesameentries asthisbimapbutwithreversedkeysandvalues. SeetheGuavaUserGuidearticleon BiMap. Since: 2.0 Author: KevinBourrillion NestedClassSummary Nestedclasses/interfacesinheritedfrominterface java.util.Map Map.Entry MethodSummary AllMethods InstanceMethods AbstractMethods  ModifierandType MethodandDescription V forcePut(K key, V value) Analternateformofputthatsilentlyremovesanyexistingentry withthevaluevaluebeforeproceedingwiththeput(K,V) operation. BiMap inverse() Returnstheinverseviewofthisbimap,whichmapseachofthisbimap's valuestoitsassociatedkey. V put(K key, V value) void putAll(Map map) Set values() Methodsinheritedfrominterface java.util.Map clear,compute,computeIfAbsent,computeIfPresent,containsKey,containsValue,entrySet,equals,forEach,get,getOrDefault,hashCode,isEmpty,keySet,merge,putIfAbsent,remove,remove,replace,replace,replaceAll,size MethodDetail put @Nullable V put(@Nullable K key, @Nullable V value) Specifiedby: put ininterface Map Throws: IllegalArgumentException-ifthegivenvalueisalreadyboundtoa differentkeyinthisbimap.Thebimapwillremainunmodifiedinthis event.Toavoidthisexception,callforcePut(K,V)instead. forcePut @Nullable V forcePut(@Nullable K key, @Nullable V value) Analternateformofputthatsilentlyremovesanyexistingentry withthevaluevaluebeforeproceedingwiththeput(K,V) operation.Ifthebimappreviouslycontainedtheprovidedkey-value mapping,thismethodhasnoeffect. Notethatasuccessfulcalltothismethodcouldcausethesizeofthe bimaptoincreasebyone,staythesame,orevendecreasebyone. Warning:Ifanexistingentrywiththisvalueisremoved,thekey forthatentryisdiscardedandnotreturned. Parameters: key-thekeywithwhichthespecifiedvalueistobeassociated value-thevaluetobeassociatedwiththespecifiedkey Returns: thevaluewhichwaspreviouslyassociatedwiththekey,whichmay benull,ornulliftherewasnopreviousentry putAll void putAll(Map map) Warning:theresultsofcallingthismethodmayvarydependingon theiterationorderofmap. Specifiedby: putAll ininterface Map Throws: IllegalArgumentException-ifanattempttoputany entryfails.Notethatsomemapentriesmayhavebeenaddedtothe bimapbeforetheexceptionwasthrown. values Set values() Becauseabimaphasuniquevalues,thismethodreturnsaSet, insteadoftheCollectionspecifiedintheMap interface. Specifiedby: values ininterface Map inverse BiMap inverse() Returnstheinverseviewofthisbimap,whichmapseachofthisbimap's valuestoitsassociatedkey.Thetwobimapsarebackedbythesamedata; anychangestoonewillappearintheother. Note:Thereisnoguaranteedcorrespondencebetweentheiteration orderofabimapandthatofitsinverse. Returns: theinverseviewofthisbimap Skipnavigationlinks Overview Package Class Use Tree Deprecated Index Help Prev Class Next Class Frames No Frames All Classes Summary:  Nested |  Field |  Constr |  Method Detail:  Field |  Constr |  Method Copyright©2010–2017.Allrightsreserved.



請為這篇文章評分?