Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SnocList {
- private char c;
- private SnocList l;
- public SnocList(){
- }
- public SnocList (char x, SnocList y) {
- this.c = x;
- this.l = y;
- }
- public char getC(){
- return this.c;
- }
- public SnocList getL(){
- return this.l;
- }
- public void setNext(SnocList input){
- this.l = input;
- }
- public boolean isEmpty() {
- if (this.c == 0) return true;
- return false;
- }
- }
- public class SnocQueue {
- private SnocList list;
- public SnocQueue(){
- this.list = new SnocList();
- }
- public void enqueue(char c){
- //I don't know what to put here
- }
- }
- public class Item {
- private int value;
- private Item next;
- public Item(int val) {
- this.value = val;
- }
- public void setNext(Item item) {
- this.next = item;
- }
- }
- public class SomeQueue {
- private Item head;
- private Item tail;
- private int size;//size is used to verify if it has Items and avoid null references
- public SomeQueue(){
- this.size = 0;
- }
- public void enqueue(Item item) {
- if (this.size > 0) {
- this.tail.setNext(item);
- this.tail = item;
- } else { //this is when the size is 0, it means is empty
- this.head = item;
- this.tail = item;
- }
- this.size++;
- }
- }
- public class SnocQueue {
- SnocList head;
- public void enqueue(char ch) {
- if(head == null) {
- head = new SnocList(ch, null);
- return;
- } else {
- SnocList curr = head;
- while (curr.l != null) {
- curr = curr.l;
- }
- curr.l = new SnocList(ch, curr.l);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement