资源描述:
《Java大数据结构与集合类.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Javacollections·Acollectionallowsagroupofobjectstobetreatedasasingleunit.Arbitraryobjectscanbestored,retrievedandmanipulatedaselementsofthesecollections.·CollectionsFrameworkpresentsasetofstandardutilityclassestomanagesuchcollections.1.Itcontains‘coreinterfaces’whi
2、challowcollectionstobemanipulatedindependentoftheirimplementations.Theseinterfacesdefinethecommonfunctionalityexhibitedbycollectionsandfacilitatedataexchangebetweencollections.2.Asmallsetofimplementationsthatareconcreteimplementationsofthecoreinterfaces,providingda
3、tastructuresthataprogramcanuse.3.Anassortmentofalgorithmstoperformvariousoperationssuchas,sortingandsearching.·Collectionsframeworkisinterfacebased,collectionsareimplementedaccordingtotheirinterfacetype,ratherthanbyimplementationtypes.Byusingtheinterfaceswheneverco
4、llectionsofobjectsneedtobehandled,interoperabilityandinterchangeabilityareachieved.·ByconventioneachofthecollectionimplementationclassesprovideaconstructortocreateacollectionbasedontheelementsintheCollectionobjectpassedasargument.Bythesametoken,Mapimplementationspr
5、ovideaconstructorthatacceptsaMapargument.Thisallowstheimplementationofacollection(Collection/Map)tobechanged.ButCollectionsandMapsarenotinterchangeable.·InterfacesandtheirimplementationsinJava1.2Collection
6、
7、__Set(nodupes,nullallowedbasedonimplementation)àHashSet
8、
9、
10、
11、
12、__SortedSet(OrderedSet)àTreeSet
13、
14、__List(orderedcollection,dupesOK)àVector,ArrayList,LinkedListMap(key-valuepairs,nullallowedbasedonimplementation)àHashTable,HashMap
15、
16、__SortedMap(OrderedMap)àTreeMapInterfaceDescriptionCollectionAbasicinterfacethatdefinestheoperatio
17、nsthatalltheclassesthatmaintaincollectionsofobjectstypicallyimplement.SetExtendsCollection,setsthatmaintainuniqueelements.SetinterfaceisdefinedintermsoftheequalsoperationSortedSetExtendsSet,maintaintheelementsinasortedorderListExtendsCollection,maintainelementsinas
18、equentialorder,duplicatesallowed.MapAbasicinterfacethatdefinesoperationsthatclassesthatrepresentmappingsofkeystovaluestypicallyimplementSortedMap