TERM Immutable Stack: I overuse stack. Poly's reply uses Collections.emptyList() as immutable list. No Collections.emptyStack(). Combining the words stack and immutability, from the last experiences, gets "immutable stack" (probably not related to functional prog).
Java Api 5 for list interface shows that Stack is an implementing class for list and arraylist, here. The java.coccurrent pkg does not have any immutable Stack data structure. The first hinted of misusing stack. The lack of immutabily in the last and poly's book recommendation leads way to list. Something very primitive, fast, no extra layers, with methods like emptyThing().
From Stack to some immutable data structure
- How to get immutable Stack data structure? Can I box it with list?
- Should I switch my current implementatios from stacks to Lists to get immutable?
- Which immutable data structure is Very fast with about similar exec time as Stack?
No immutability to Stack with Final
import java.io.*;
import java.util.*;
public class TestStack{
public static void main(String[] args)
{
final Stack<Integer> test = new Stack<Integer>();
Stack<Integer> test2 = new Stack<Integer>();
test.push(37707);
test2.push(80437707);
//WHY is there not an error to remove an elment
// from FINAL stack?
System.out.println(test.pop());
System.out.println(test2.pop());
}
}
[Added]
Overuse of stack
DataFile.java: public Stack<DataFile> files;
FileObject.java: public Stack<String> printViews = new Stack<String>();
FileObject.java:// private static Stack<Object> getFormat(File f){return (new Format(f)).getFormat();}
Format.java: private Stack<Object> getLine(File[] fs,String s){return wF;}
Positions.java: public static Stack<Integer[]> getPrintPoss(String s,File f,Integer maxViewPerF)
Positions.java: Stack<File> possPrint = new Stack<File>();
Record.java: private String getFormatLine(Stack<Object> st)
SearchToUser.java: public static final Stack<File> allFiles = findf.getFs();
View.java: public Stack<Integer[]> poss = new Stack<Integer[4]>();