diff options
Diffstat (limited to 'src/semanticanalysis')
-rw-r--r-- | src/semanticanalysis/Share.java | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/semanticanalysis/Share.java b/src/semanticanalysis/Share.java new file mode 100644 index 0000000..c1f03c2 --- /dev/null +++ b/src/semanticanalysis/Share.java @@ -0,0 +1,37 @@ +package semanticanalysis; + +import java.util.ArrayList; + +public class Share { + + public static <T> ArrayList<T> removeDuplicates(ArrayList<T> list) { + ArrayList<T> newList = new ArrayList<T>(); + + for (T element : list) { + if (!customContains(newList, element)) { + newList.add(element); + } + } + return newList; + } + + public static <T> boolean customContains(ArrayList<T> list, T e) { + String e1 = e.toString(); + for (T element : list) { + String e2 = element.toString(); + if (e2.equals(e1)) { + return true; + } + } + return false; + } + + public static String getExtension(String fileName) { + int extensionIndex = fileName.lastIndexOf('.'); + if (extensionIndex == -1) { + return fileName; + } else { + return fileName.substring(extensionIndex + 1); + } + } +} |