Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

New answers tagged

0

import java.util.*; class Cqueue { int arr[]; int rear,front,capacity; Cqueue(int size) { arr=new int[size]; rear=-1; front=-1; capacity=size; } void enqueue(int x) { if(front==rear+1) { System.out.println("Queue is full"); } else if(front==-1 && rear==-1) { front=rear=0; ...


1

Observations The class is not thread-safe, so why is method doubleBackingArraySize synchronized? All methods perform some sort of redundancy in circular incrementation and decrementation. This kind of arithmetic could be placed in 2 separate methods, which you would then call in the other methods to have more DRY code. Deciding when to allocate more space ...


Top 50 recent answers are included