Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SpecialQueue<ELEMENT> extends java.util.ArrayDeque<ELEMENT> {
- public SpecialQueue() {
- this(10);
- }
- public SpecialQueue(int capacity) {
- super(capacity);
- }
- public SpecialQueue<ELEMENT> join(SpecialQueue<ELEMENT> other) {
- SpecialQueue<ELEMENT> result =
- new SpecialQueue<ELEMENT>((this.size() + other.size()) * 2);
- ELEMENT[] data = (ELEMENT[]) this.toArray();
- for (ELEMENT e : data) {
- result.add(e);
- }
- data = (ELEMENT[]) other.toArray();
- for (ELEMENT e : data) {
- result.add(e);
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement