MCPcopy Create free account
hub / github.com/MolinDeng/Princeton-algs4 / resize

Method resize

LabEnv/02Lab/RandomizedQueue.java:38–45  ·  view source on GitHub ↗
(int capacity)

Source from the content-addressed store, hash-verified

36 }
37
38 private void resize(int capacity) {
39 Item[] copy = (Item[]) new Object[capacity];
40 for (int i = 0; i < n; i++)
41 copy[i] = v[(first + i) % v.length];
42 v = copy;
43 first = 0;
44 last = n;
45 }
46
47 // add the item
48 public void enqueue(Item item) {

Callers 2

enqueueMethod · 0.95
dequeueMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected