GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Update Java集合框架常见面试题.md · zjtech/JavaGuide@fb609a8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs/java/collection
    • Java集合框架常见面试题.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/java/collection/Java集合框架常见面试题.md‎

Copy file name to clipboardExpand all lines: docs/java/collection/Java集合框架常见面试题.md
+6-6Lines changed: 6 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ Output:
333333

334334
`Deque` 扩展了 `Queue` 的接口, 增加了在队首和队尾进行插入和删除的方法,同样根据失败后处理方式的不同分为两类:
335335

336-
| `Deque`接口 | 抛出异常 | 返回特殊值 |
336+
| `Deque` 接口 | 抛出异常 | 返回特殊值 |
337337
| ------------ | ------------- | --------------- |
338338
| 插入队首 | addFirst(E e) | offerFirst(E e) |
339339
| 插入队尾 | addLast(E e) | offerLast(E e) |
@@ -342,12 +342,12 @@ Output:
342342
| 查询队首元素 | getFirst() | peekFirst() |
343343
| 查询队尾元素 | getLast() | peekLast() |
344344

345-
事实上,`Deque` 还提供有 `push()` 和 `pop()` 等其他方法,用于模拟栈。
345+
事实上,`Deque` 还提供有 `push()` 和 `pop()` 等其他方法,可用于模拟栈。
346346

347347

348348
### 1.4.2 ArrayDeque 与 LinkedList 的区别
349349

350-
`ArrayDeque` 和 `LinkedList` 都实现了`Deque`接口,两者都具有队列的功能,但两者有什么区别呢?
350+
`ArrayDeque` 和 `LinkedList` 都实现了 `Deque` 接口,两者都具有队列的功能,但两者有什么区别呢?
351351

352352
- `ArrayDeque` 是基于可变长的数组和双指针来实现,而 `LinkedList` 则通过链表来实现。
353353

@@ -357,7 +357,7 @@ Output:
357357

358358
- `ArrayDeque` 插入时可能存在扩容过程, 不过均摊后的插入操作依然为 O(1)。虽然 `LinkedList` 不需要扩容,但是每次插入数据时均需要申请新的堆空间,均摊性能相比更慢。
359359

360-
从性能的角度上,选用 `ArrayDeque` 去实现队列要比 `LinkedList` 更好。此外,`ArrayDeque` 也可以用于实现栈。
360+
从性能的角度上,选用 `ArrayDeque` 来实现队列要比 `LinkedList` 更好。此外,`ArrayDeque` 也可以用于实现栈。
361361

362362
### 1.4.3 说一说 PriorityQueue
363363

@@ -368,9 +368,9 @@ Output:
368368
- `PriorityQueue` 利用了二叉堆的数据结构来实现的,底层使用可变长的数组来存储数据
369369
- `PriorityQueue` 通过堆元素的上浮和下沉,实现了在 O(logn) 的时间复杂度内插入元素和删除堆顶元素。
370370
- `PriorityQueue` 是非线程安全的,且不支持存储 `NULL` 和 `non-comparable` 的对象。
371-
- `PriorityQueue` 默认是小顶堆,可以接收一个`Comparator`作为构造参数来比较队列中元素的优先级。
371+
- `PriorityQueue` 默认是小顶堆,但可以接收一个 `Comparator` 作为构造参数,从而来自定义元素优先级的先后。
372372

373-
`PriorityQueue` 在面试中可能更多的会出现在手撕算法的时候,典型例题包括堆排序、求第K大的数、带权图的遍历等,所以需要学会熟练使用才行。
373+
`PriorityQueue` 在面试中可能更多的会出现在手撕算法的时候,典型例题包括堆排序、求第K大的数、带权图的遍历等,所以需要会熟练使用才行。
374374

375375
## 1.5. Map 接口
376376

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.