Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- MoveToFrontList list = new MoveToFrontList();
- list.incrementCount("hi");
- list.displayAll();
- list.incrementCount("hi");
- list.incrementCount("hi");
- list.incrementCount("hi");
- list.incrementCount("hi");
- list.incrementCount("hi");
- list.incrementCount("hello");
- list.incrementCount("hello");
- list.incrementCount("hello");
- list.incrementCount("haha");
- list.displayAll();
- StringCountElement elem1 = new StringCountElement();
- elem1.key = "elem1";
- elem1.count = 3;
- StringCountElement elem2 = new StringCountElement();
- elem2.key = "elem2";
- elem2.count = 3;
- StringCountElement elem3 = new StringCountElement();
- elem3.key = "elem3";
- elem3.count = 3;
- list.spliceIn(elem3, 0);
- list.spliceIn(elem2, list.size());
- list.displayAll();
- list.spliceIn(elem1, 2);
- list.spliceOut(elem2);
- list.spliceIn(elem2, 0);
- list.displayAll();
- System.out.println();
- System.out.println("Test Set 2:");
- MoveToFrontList other = new MoveToFrontList();
- StringCountElement otherElem1 = new StringCountElement();
- otherElem1.key = "other1";
- otherElem1.count = 1;
- StringCountElement otherElem2 = new StringCountElement();
- otherElem2.key = "other2";
- otherElem2.count = 1;
- StringCountElement otherElem3 = new StringCountElement();
- otherElem3.key = "other3";
- otherElem3.count = 1;
- StringCountElement otherElem4 = new StringCountElement();
- otherElem4.key = "other4";
- otherElem4.count = 1;
- other.spliceIn(otherElem1, 0);
- other.spliceIn(otherElem2, 1);
- other.spliceIn(otherElem3, 2);
- other.spliceIn(otherElem4, 2);
- other.displayAll();
- other.spliceOut(otherElem3);
- System.out.println("The following value should be null: " + otherElem4.next);
- other.displayAll();
- other.spliceOut(otherElem4);
- System.out.println("The following value should be null: " + otherElem2.next);
- other.displayAll();
- other.spliceOut(otherElem2);
- System.out.println("The following value should be null: " + otherElem1.next);
- other.displayAll();
- other.spliceOut(otherElem1);
- other.displayAll();
- other.spliceOut(otherElem1);
- other.displayAll();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement