Class ArraysAlgos
- java.lang.Object
-
- org.processmining.logfiltering.algorithms.SPMF.PatternMining.ArraysAlgos
-
public class ArraysAlgos extends java.lang.ObjectThis class provides a set of basic methods that can be used with itemsets represented as arrays of integers. All the methods are static methods so that they can be used in any classes.- Author:
- Philippe Fournier-Viger
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<int[]>comparatorItemsetSameSizeA Comparator for comparing two itemsets having the same size using the lexical order.
-
Constructor Summary
Constructors Constructor Description ArraysAlgos()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanallTheSameExceptLastItem(int[] itemset1, int[] itemset2)This method checks if this itemset is the same as another itemset except for the last item.static int[]appendIntegerToArray(int[] array, int integer)Append an integer at the end of an array of integers.static int[]cloneItemSetMinusAnItemset(int[] itemset, int[] itemsetToNotKeep)Make a copy of this itemset but exclude a set of itemsstatic int[]cloneItemSetMinusOneItem(int[] itemset, java.lang.Integer itemToRemove)Make a copy of this itemset but exclude a given itemstatic int[]concatenate(int[] prefix, int[] suffix)Method to concatenate two arrays in a new arraystatic booleancontains(int[] itemset, int item)Check if an a sorted list of integers contains an integer.static booleancontainsLEX(int[] itemset, int item)This method checks if the item "item" is in the itemset.static booleancontainsLEX(java.lang.Integer[] itemset, java.lang.Integer item, int maxItemInArray)This method checks if an item "item" is in the itemset "itemset".static booleancontainsLEXPlus(int[] itemset, int item)This method checks if the item "item" is in the itemset.static booleancontainsOrEquals(java.lang.Integer[] itemset1, java.lang.Integer[] itemset2)Check if an itemset contains another itemset.static double[]convertStringArrayToDoubleArray(java.lang.String[] tokens)Convert a string array to a double arraystatic booleanincludedIn(int[] itemset1, int[] itemset2)Check if a sorted itemset is contained in anotherstatic booleanincludedIn(int[] itemset1, int itemset1Length, int[] itemset2)Check if a sorted itemset is contained in anotherstatic int[]intersectTwoSortedArrays(int[] array1, int[] array2)This method performs the intersection of two sorted arrays of integers and return a new sorted array.static intsameAs(int[] itemset1, int[] itemsets2, int posRemoved)Method to compare two sorted list of integers and see if they are the same, while ignoring an item from the second list of integer.
-
-
-
Method Detail
-
cloneItemSetMinusOneItem
public static int[] cloneItemSetMinusOneItem(int[] itemset, java.lang.Integer itemToRemove)Make a copy of this itemset but exclude a given item- Parameters:
itemToRemove- the given item- Returns:
- the copy
-
cloneItemSetMinusAnItemset
public static int[] cloneItemSetMinusAnItemset(int[] itemset, int[] itemsetToNotKeep)Make a copy of this itemset but exclude a set of items- Parameters:
itemsetToNotKeep- the set of items to be excluded- Returns:
- the copy
-
allTheSameExceptLastItem
public static boolean allTheSameExceptLastItem(int[] itemset1, int[] itemset2)This method checks if this itemset is the same as another itemset except for the last item. It assumes that both itemsets have the same length.- Parameters:
itemset1- the first itemsetitemset2- the second itemset- Returns:
- true if they are the same except for the last item
-
concatenate
public static int[] concatenate(int[] prefix, int[] suffix)Method to concatenate two arrays in a new array- Parameters:
prefix- the first arraysuffix- the second array- Returns:
- the resulting array
-
intersectTwoSortedArrays
public static int[] intersectTwoSortedArrays(int[] array1, int[] array2)This method performs the intersection of two sorted arrays of integers and return a new sorted array.- Parameters:
a- the first arrayb- the second array- Returns:
- the resulting sorted array
-
containsOrEquals
public static boolean containsOrEquals(java.lang.Integer[] itemset1, java.lang.Integer[] itemset2)Check if an itemset contains another itemset. It assumes that itemsets are sorted according to the lexical order.- Parameters:
itemset1- the first itemsetitemset2- the second itemset- Returns:
- true if the first itemset contains the second itemset
-
containsLEX
public static boolean containsLEX(java.lang.Integer[] itemset, java.lang.Integer item, int maxItemInArray)This method checks if an item "item" is in the itemset "itemset". It assumes that items in the itemset are sorted in lexical order and that the largest item in the itemset is known.- Parameters:
itemset- an itemsetitem- the itemmaxItemInArray- the largest item in the itemset- Returns:
- returnt true if the item appears in the itemset
-
sameAs
public static int sameAs(int[] itemset1, int[] itemsets2, int posRemoved)Method to compare two sorted list of integers and see if they are the same, while ignoring an item from the second list of integer. This methods is used by some Apriori algorithms.- Parameters:
itemset1- the first itemsetitemsets2- the second itemsetposRemoved- the position of an item that should be ignored from "itemset2" to perform the comparison.- Returns:
- 0 if they are the same, 1 if itemset is larger according to lexical order, -1 if smaller.
-
includedIn
public static boolean includedIn(int[] itemset1, int[] itemset2)Check if a sorted itemset is contained in another- Parameters:
itemset1- the first itemsetitemset2- the second itemset- Returns:
- true if yes, otherwise false
-
includedIn
public static boolean includedIn(int[] itemset1, int itemset1Length, int[] itemset2)Check if a sorted itemset is contained in another- Parameters:
itemset1- the first itemsetlength- of the first itemsetitemset2- the second itemset- Returns:
- true if yes, otherwise false
-
containsLEXPlus
public static boolean containsLEXPlus(int[] itemset, int item)This method checks if the item "item" is in the itemset. It asumes that items in the itemset are sorted in lexical order This version also checks that if the item "item" was added it would be the largest one according to the lexical order.- Parameters:
itemset- an itemsetitem- the item- Returns:
- return true if the above conditions are met, otherwise false
-
containsLEX
public static boolean containsLEX(int[] itemset, int item)This method checks if the item "item" is in the itemset. It assumes that items in the itemset are sorted in lexical order- Parameters:
itemset- an itemsetitem- the item- Returns:
- return true if the item
-
contains
public static boolean contains(int[] itemset, int item)Check if an a sorted list of integers contains an integer.- Parameters:
itemset- the sorted list of integersitem- the integer- Returns:
- true if the item appears in the list, false otherwise
-
appendIntegerToArray
public static int[] appendIntegerToArray(int[] array, int integer)Append an integer at the end of an array of integers.- Parameters:
array- the arrayinteger- the integer- Returns:
- a new array
-
convertStringArrayToDoubleArray
public static double[] convertStringArrayToDoubleArray(java.lang.String[] tokens)
Convert a string array to a double array- Parameters:
tokens- a string array- Returns:
- a double array
-
-