Danh mục

Bài giảng Cấu trúc dữ liệu: Chương 14 - Nguyễn Xuân Vinh

Số trang: 22      Loại file: pptx      Dung lượng: 379.35 KB      Lượt xem: 8      Lượt tải: 0    
Jamona

Hỗ trợ phí lưu trữ khi tải xuống: 14,000 VND Tải xuống file đầy đủ (22 trang) 0
Xem trước 3 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Bài giảng Cấu trúc dữ liệu - Chương 14: Conllectinons framework introduction to collections, what is a collections framework, collections interface, collections implementations, collections comparision,...
Nội dung trích xuất từ tài liệu:
Bài giảng Cấu trúc dữ liệu: Chương 14 - Nguyễn Xuân VinhGV: NGUYỄN XUÂN VINH CẤU TRÚC DỮ LIỆU DATA STRUCTURES [214441] COLLECTIONs FRAMEWORKMÔN: CẤU TRÚC DỮ LIỆU Nguyễn Xuân Vinh nguyenxuanvinh@hcmuaf.edu.6/12/14 vn/XX1GV: NGUYỄN XUÂN VINH Introduction to Collections • Acollection—sometimescalledacontainer—issimplyanobject thatgroupsmultipleelementsintoasingleunit. • Collectionsareusedtostore,retrieve,manipulate,and communicateaggregatedata. • Representdataitemsthatformanaturalgroup,suchas:MÔN: CẤU TRÚC DỮ LIỆU – Apokerhand(acollectionofcards) – Amailfolder(acollectionofletters) – Atelephonedirectory(amappingofnamestophonenumbers)6/12/14/XX2GV: NGUYỄN XUÂN VINH What is a Collections Framework • Acollections frameworkisaunifiedarchitectureforrepresenting andmanipulatingcollections. • Allcollectionsframeworkscontainthefollowing: – Interfaces:Theseareabstractdatatypesthatrepresent collectionsMÔN: CẤU TRÚC DỮ LIỆU – Implementations:Thesearetheconcreteimplementationsof thecollectioninterfaces. – Algorithms:Thesearethemethodsthatperformuseful computations,suchassearchingandsorting6/12/14/XX34 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Collections Interface5 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Collections Implementations6 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Collections Implementations7 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Collection Implementations8 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Concrete Classes: Collection9 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Concrete Class: MAP10 /XX 6/12/14 MÔN: CẤU TRÚC DỮ LIỆU GV: NGUYỄN XUÂN VINH Collections ComparisionGV: NGUYỄN XUÂN VINH 1) Collection Interface:Traversing Collections • Therearetwowaystotraversecollections: – (1)withthefor-eachconstruct for (Object o : collection) System.out.println(o);MÔN: CẤU TRÚC DỮ LIỆU – (2)byusingIterators. Iterator iterator = collection.iterator(); while(iterator.hasNext()) { System.out.println(iterator.next()); }6/12/14/XX11GV: NGUYỄN XUÂN VINH 2) Collection Interface: Bulk Operations • containsAll—returnstrueifthetargetCollectioncontainsallof theelementsinthespecifiedCollection. • addAll—addsalloftheelementsinthespecifiedCollectiontothe targetCollection. • removeAll—removesfromthetargetCollectionallofitselementsMÔN: CẤU TRÚC DỮ LIỆU thatarealsocontainedinthespecifiedCollection. • retainAll—removesfromthetargetCollectionallitselementsthat ...

Tài liệu được xem nhiều: