Common Data Structures

17 3.4K 0
Common Data Structures

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Common Data Structures

Common Data Structures Mini Report Hien Vu 4/15/2014 ArrayList Linked List Hash Map Hash Set 1 • ArrayLi st Remind: Array 1 • ArrayLi st Remind: Array Ex: int[] number = new int[100]; => fixed-size array declaration Problems: ??? 1 • ArrayLi st Array Lists: offer two significant benefits:  Array lists can grow and shrink as needed.  The ArrayList class supplies methods for many common tasks, such as inserting and removing elements. 1 • ArrayLi st Syntax: 1 • ArrayLi st Figure 1.1 Adding an Element with add 1 • ArrayLi st Figure 1.2 Adding and Removing Elements in the Middle of an Array List 1 • ArrayLi st SN Methods with Description 1 void add(int index, Object element) Inserts the specified element at the specified position index in this list. 2 boolean add(Object o) Appends the specified element to the end of this list. 3 boolean addAll(int index, Collection c) Inserts all of the elements in the specified collection into this list, starting at the specified position. 4 boolean contains(Object o) Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)). 5 Object get(int index) Returns the element at the specified position in this list. 6 Object remove(int index) Removes the element at the specified position in this list. 7 int size() Returns the number of elements in this list. 2 • Linked List A linked list is a data structure used for collecting a sequence of objects that allows efficient addition and removal of elements in the middle of the sequence.

Ngày đăng: 06/05/2014, 17:10

Mục lục

  • Slide 1

  • Slide 2

  • Slide 3

  • Slide 4

  • Slide 5

  • Slide 6

  • Slide 7

  • Slide 8

  • Slide 9

  • Slide 10

  • Slide 11

  • Slide 12

  • Slide 13

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan