|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | ||||||||
java.lang.Objectcoser.common.SimpleTool
public class SimpleTool extends java.lang.Object
Frequently used methods to convert strings, integers, codings, etc.
Author: Fan Min minfanphd@163.com
Copyright: The source code and all documents are open and free. PLEASE keep
this header while revising the program.
Organization: Lab of Granular Computing,
Zhangzhou Normal University, Fujian 363000, China.
Project: The cost-sensitive rough sets project.
Progress: OK. Copied from Hydrosimu.
Written time: March 09, 2011.
Last modify time: March 09, 2011.
| 修饰符 和 类型 | 字段 和 描述 |
|---|---|
static int |
MAX_PARSE_ARRAY_LENGTH
Maximal length of the parsed array (for int and double). |
static java.util.Random |
random
A global random object. |
| 构造函数 和 描述 |
|---|
SimpleTool()
|
| 修饰符 和 类型 | 方法 和 描述 |
|---|---|
static java.lang.String |
addSingleQuotes(java.lang.String prmStringArray)
Add single quotes for a string (may be an array, elements are separated by commas). |
static long[] |
adjustLongArrayLength(long[] paraLongArray,
int length)
Adjust a long array length. |
static int |
attributeSubsetSize(boolean[] paraBooleanArray)
Compute the attribute subset size. |
static int |
attributeSubsetSize(long paraLong,
int paraLength)
Compute the attribute subset size. |
static java.lang.String |
booleanArrayToAttributeSetString(boolean[] paraArray)
Conver a boolean array into a string. |
static int |
booleanArrayToInt(boolean[] paraBooleanArray)
Convert a boolean array to an int value. |
static long |
booleanArrayToLong(boolean[] paraBooleanArray)
Convert a boolean array to a long value. |
static java.lang.String |
booleanArrayToString(boolean[] paraArray,
char paraSeparator)
Convert a boolean array into a string. |
static java.lang.String |
booleanMatrixToString(boolean[][] tempMatrix)
Convert a boolean matrix to string |
static boolean[][] |
children(int paraBits)
Who is who's child. |
static int[] |
compressAndSortIntArray(int[] paraIntArray,
int paraLength)
Compress an int array so that no duplicate elements, no redundant elemnts exist, and it is in an ascendent order. |
static long[] |
compressAndSortLongArray(long[] paraLongArray,
int paraLength)
Compress a long array so that no duplicate elements, no redundant elemnts exist, and it is in an ascendent order. |
static boolean[] |
copyBooleanArray(boolean[] paramBooleanArray)
Copy boolean array |
static java.lang.String |
doubleArrayToString(double[] paraArray)
Conver a double array into a string. |
static java.lang.String |
doubleArrayToString(double[] paraArray,
char paraSeparator)
Conver a double array into a string. |
static int |
exponential(int paraExponential)
The exponential of an int. |
static long |
exponentialLong(int paraExponential)
The exponential of an int. |
static java.lang.String |
GB2312ToUNICODE(java.lang.String paraString)
GB2312 to UNICODE. |
static boolean[] |
generateBooleanArrayForDivision(int paraDatasetSize,
double paraPercentage)
Generate a boolean array to divide a dataset in two |
static java.lang.String |
generateString(java.lang.String[] prmString,
int index)
Remove string from a string array, and return a string. |
static int |
getSubsetSize(boolean[] paraSubset)
Return the size of the subset. |
static int |
getSubsetSize(long paraSubset)
Return the size of the subset. |
static java.lang.String |
intArrayToAttributeSetString(int[] paraIntArray,
int paraLength)
An int array to an attribute subset. |
static int |
intArrayToInt(int[] paraIntArray)
An int array to an int value. |
static long |
intArrayToLong(int[] paraIntArray)
An int array to an long value. |
static java.lang.String |
intArrayToString(int[] paraArray,
char paraSeparator)
Convert an integer array into a string. |
static java.lang.String |
intToAttributeSetString(int paraInt)
An int to an attribute subset. |
static boolean[] |
intToBooleanArray(int paraInt,
int paraLength)
Convert an integer value to a boolean array. |
static boolean |
isAscendingOrder(int[] paraArray)
Is the given array in an ascending order? |
static boolean |
isEmptyStr(java.lang.String paraString)
Judge whether or not the given string is null/empty. |
static boolean |
isSubset(boolean[] paraFirstSet,
boolean[] paraSecondSet)
Is the first set a subset of the second one. |
static boolean |
isSubset(int[] paraFirstSet,
int[] paraSecondSet)
Is the first set a subset of the second one. |
static boolean |
isSubset(long paraFirstSet,
long paraSecondSet,
int paraAttributes)
Is the first set a subset of the second one. |
static boolean |
isUnspecifiedStr(java.lang.String paraString)
Judge whether or not the given string is specified. |
static boolean |
isUpperTriangleBooleanMatrix(boolean[][] paraMatrix)
Judge whether or not the given boolean matrix is upper triangle one. |
static java.lang.String |
joinString(java.lang.String prmFirstString,
java.lang.String prmSecondString)
Join two attribute strings, separated by a comma. |
static boolean[][] |
longArrayToBooleanMatrix(long[] paraLongArray,
int paraLength)
Long array to boolean matrix. |
static java.lang.String |
longToAttributeSetString(long paraLong)
A long to an attribute subset. |
static java.lang.String |
longToBitString(long paraLong)
Convert a long value to a bit string. |
static boolean[] |
longToBooleanArray(long paraLong,
int paraLength)
Convert a long value to a boolean array. |
static int[] |
longToIntArray(long paraLong,
int paraLength)
Convert a long value to a integer array. |
static void |
main(java.lang.String[] args)
Testing method. |
static void |
measureBasedQuickSort(long[] paraData,
int[] paraMeasuredValues,
int paraLeft,
int paraRight)
Subreduct sort according to respective measure. |
static double[] |
parseDoubleArray(java.lang.String paraString)
Read a double array from a given string. |
static double[] |
parseDoubleArray(java.lang.String paraString,
int paraNumberOfDoubles,
char paraSeparator)
Read a double array from a given string. |
static double |
parseDoubleValueAfterColon(java.lang.String paraString)
Read a double value from a given string after the colon. |
static int[] |
parseIntArray(java.lang.String paraString)
Read a int array from a given string. |
static int[] |
parseIntArray(java.lang.String paraString,
int paraNumberOfInts,
char paraSeparator)
Read an integer array from a given string. |
static int |
parseIntValueAfterColon(java.lang.String paraString)
Read an int value from a given string after the colon. |
static java.lang.String[] |
parseString(java.lang.String prmString,
java.lang.String prmDelimiter,
boolean prmReturnTokens)
Convert a string with delimiters (such as commas or semi-commas) into a string array. |
static void |
printAllReducts(boolean[][] paraAllReducts)
Print all reducts. |
static void |
printBooleanArray(boolean[] paraBooleanArray)
Print a boolean array. |
static void |
printBooleanMatrix(boolean[][] paraBooleanMatrix)
Print a boolean matrix. |
static void |
printDoubleArray(double[] paraDoubleArray)
Print a double array. |
static void |
printIntArray(int[] paraIntArray)
Print an int array, simply for test. |
static void |
printLongArray(long[] paraLongArray)
Print a long array, simply for test. |
static void |
printLongArrayNoZero(long[] paraLongArray)
Print a long array, zero is not printed. |
static long[] |
removeSupersets(long[] paraSets,
int paraNumberOfConditions)
Remove supersets, used to obtain reducts. |
static boolean[] |
revertBooleanArray(boolean[] paraArray)
Revert a boolean array. |
static int[] |
setIntersection(int[] paraFirstSet,
int[] paraSecondSet)
Set intersection. |
static java.lang.String |
shorterDouble(double paraDouble)
Convert a double value into a shorter string. |
static java.lang.String |
shorterDouble(double paraDouble,
int paraLength)
Convert a double value into a shorter string. |
static boolean |
stringArrayContainsString(java.lang.String prmStringArray,
java.lang.String prmString)
If the string quisi-array (elements are separated by commas) contains respective attribute. |
static java.lang.String |
stringArrayToString(java.lang.String[] prmStringArray)
Convert a string array into a string, elements are separated by commas. |
static java.lang.String |
stringMinusString(java.lang.String prmFirstString,
java.lang.String prmSecondString)
One string minus another, essentially corresponding string arrays. |
static boolean[] |
stringToBooleanArray(java.lang.String paraString,
char paraSeparator)
Convert a string array into a boolean array. |
static java.lang.String[] |
stringToStringArray(java.lang.String prmString)
Convert a string with commas into a string array, blanks adjacent with commas are deleted. |
static java.lang.String |
stringUnionString(java.lang.String prmFirstString,
java.lang.String prmSecondString)
One string union another, essentially corresponding string sets. |
static char |
subSetCheck(long paraFirstSet,
long paraSecondSet,
int paraNumberOfConditions)
Check Who is who's subset. |
static void |
swap(double[] paraDoubleArray,
int src,
int dest)
Swap two value in a double array. |
static void |
swap(int[] paraLongArray,
int src,
int dest)
Swap two value in a long array. |
static void |
swap(long[] paraLongArray,
int src,
int dest)
Swap two value in a long array. |
static java.lang.String |
UNICODEToGB2312(java.lang.String paraString)
UNICODE to GB2312. |
| 从类 java.lang.Object 继承的方法 |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 字段详细信息 |
|---|
public static final int MAX_PARSE_ARRAY_LENGTH
public static final java.util.Random random
| 构造方法详细信息 |
|---|
public SimpleTool()
| 方法详细信息 |
|---|
public static java.lang.String shorterDouble(double paraDouble)
paraDouble - the double value to be converted.
public static java.lang.String shorterDouble(double paraDouble,
int paraLength)
paraDouble - the double value to be converted.paraLength - the length of reserved double.
public static java.lang.String[] stringToStringArray(java.lang.String prmString)
throws java.lang.Exception
prmString - The source stringjava.lang.Exception - Exception for illegal data.stringArrayToString(java.lang.String[])public static java.lang.String stringArrayToString(java.lang.String[] prmStringArray)
prmStringArray - The source string arraystringToStringArray(java.lang.String)public static java.lang.String addSingleQuotes(java.lang.String prmStringArray)
prmStringArray - The source string
public static boolean stringArrayContainsString(java.lang.String prmStringArray,
java.lang.String prmString)
prmStringArray - The string quisi-array (elements are separated by commas).prmString - Respect string.stringToStringArray(java.lang.String)
public static java.lang.String joinString(java.lang.String prmFirstString,
java.lang.String prmSecondString)
prmFirstString - The first attribute stringprmSecondString - The second attribute string
public static java.lang.String[] parseString(java.lang.String prmString,
java.lang.String prmDelimiter,
boolean prmReturnTokens)
prmString - The given stringprmDelimiter - The given delimiterprmReturnTokens - Is the delimiter permitted after convertion.
public static java.lang.String generateString(java.lang.String[] prmString,
int index)
prmString - 字符串index - 去掉串的位?public static java.lang.String GB2312ToUNICODE(java.lang.String paraString)
paraString - a GB2312 stringUNICODEToGB2312(java.lang.String)public static java.lang.String UNICODEToGB2312(java.lang.String paraString)
paraString - a UNICODE string.GB2312ToUNICODE(java.lang.String)
public static java.lang.String stringMinusString(java.lang.String prmFirstString,
java.lang.String prmSecondString)
throws java.lang.Exception
prmFirstString - The first string.prmSecondString - The second string.java.lang.Exception - if the first string does not contain an element of the second
string, e.g., "ab, cd" minus "ab, de". #see
scheme.SymbolicPartition
.computeOptimalPartitionReduct(java.lang.String,
java.lang.String, int)
public static java.lang.String stringUnionString(java.lang.String prmFirstString,
java.lang.String prmSecondString)
throws java.lang.Exception
prmFirstString - The first string.prmSecondString - The second string.java.lang.Exceptionpublic static boolean isEmptyStr(java.lang.String paraString)
public static boolean isUnspecifiedStr(java.lang.String paraString)
public static int[] parseIntArray(java.lang.String paraString,
int paraNumberOfInts,
char paraSeparator)
throws java.lang.Exception
paraString - The given string.paraNumberOfInts - The number of integer to read from the string. If there are
more integers, just ignore them.paraSeparator - The separator of data, blank and commas are most commonly uses
ones.java.lang.Exceptionpublic static java.lang.String intToAttributeSetString(int paraInt)
paraInt - The given integer representing an attribute subset.
public static java.lang.String intArrayToAttributeSetString(int[] paraIntArray,
int paraLength)
paraIntArray - The given integer array an attribute subset.paraLength - The size of the subset.public static int intArrayToInt(int[] paraIntArray)
paraIntArray - The given integer array indicating which positions is 1.public static long intArrayToLong(int[] paraIntArray)
paraIntArray - The given integer representing an attribute subset.intArrayToInt(int[])public static java.lang.String longToAttributeSetString(long paraLong)
paraLong - The given integer representing an attribute subset.
public static java.lang.String intArrayToString(int[] paraArray,
char paraSeparator)
throws java.lang.Exception
paraArray - The given array.paraSeparator - The separator of data, blank and commas are most commonly uses
ones.java.lang.Exception
public static double[] parseDoubleArray(java.lang.String paraString,
int paraNumberOfDoubles,
char paraSeparator)
throws java.lang.Exception
paraString - The given string.paraNumberOfDoubles - The number of integer to read from the string. If there are
more integers, just ignore them.paraSeparator - The separator of data, blank and commas are most commonly uses
ones.java.lang.Exception
public static double[] parseDoubleArray(java.lang.String paraString)
throws java.lang.Exception
paraString - The given string.java.lang.Exception
public static java.lang.String doubleArrayToString(double[] paraArray)
throws java.lang.Exception
paraArray - The given array.java.lang.Exception
public static java.lang.String doubleArrayToString(double[] paraArray,
char paraSeparator)
throws java.lang.Exception
paraArray - The given array.paraSeparator - The separator of data, blank and commas are most commonly uses
ones.java.lang.Exception
public static java.lang.String booleanArrayToString(boolean[] paraArray,
char paraSeparator)
paraArray - The given array.paraSeparator - The separator of data, blank and commas are most commonly uses
ones.
public static boolean[] stringToBooleanArray(java.lang.String paraString,
char paraSeparator)
throws java.lang.Exception
paraString - The given string.paraSeparator - The separator of data, blank and commas are most commonly uses
ones.java.lang.Exception - for wrong format.public static java.lang.String booleanArrayToAttributeSetString(boolean[] paraArray)
paraArray - The given array.
public static int[] parseIntArray(java.lang.String paraString)
throws java.lang.Exception
paraString - The given string.java.lang.Exception
public static double parseDoubleValueAfterColon(java.lang.String paraString)
throws java.lang.Exception
paraString - The given string.java.lang.Exception
public static int parseIntValueAfterColon(java.lang.String paraString)
throws java.lang.Exception
paraString - The given string.java.lang.Exception
public static int[] compressAndSortIntArray(int[] paraIntArray,
int paraLength)
paraIntArray - The given int array.paraLength - The effecitive length of the given int array.
public static long[] compressAndSortLongArray(long[] paraLongArray,
int paraLength)
paraLongArray - The given long array.paraLength - The effecitive length of the given long array.
public static void measureBasedQuickSort(long[] paraData,
int[] paraMeasuredValues,
int paraLeft,
int paraRight)
throws java.lang.Exception
paraData - The data, it may represent a subreductparaMeasuredValues - The measured values of the dataparaLeft - The left index.paraRight - The right index.java.lang.Exception
public static long[] adjustLongArrayLength(long[] paraLongArray,
int length)
paraLongArray - The given long array.length - The real length of the given long array.public static boolean[] copyBooleanArray(boolean[] paramBooleanArray)
paramBooleanArray - The given boolean array.public static int exponential(int paraExponential)
paraExponential - the exponential.public static long exponentialLong(int paraExponential)
paraExponential - the exponential.public static boolean[][] children(int paraBits)
paraBits - How many bits (attributes).
public static int[] longToIntArray(long paraLong,
int paraLength)
paraLong - The given long value.paraLength - The given length of the array.
public static boolean[] longToBooleanArray(long paraLong,
int paraLength)
paraLong - The given long value.paraLength - The given length of the array.
public static long booleanArrayToLong(boolean[] paraBooleanArray)
throws java.lang.Exception
paraBooleanArray - The given boolean array.java.lang.Exception
public static int attributeSubsetSize(long paraLong,
int paraLength)
paraLong - The given long value.paraLength - The size of all attributes.public static int attributeSubsetSize(boolean[] paraBooleanArray)
paraBooleanArray - The given boolean array.
public static boolean[] intToBooleanArray(int paraInt,
int paraLength)
paraInt - The given long value.paraLength - The given length of the array.
public static int booleanArrayToInt(boolean[] paraBooleanArray)
throws java.lang.Exception
paraBooleanArray - The given boolean array.java.lang.Exceptionpublic static void printIntArray(int[] paraIntArray)
paraIntArray - The given int array.public static void printLongArray(long[] paraLongArray)
paraLongArray - The given long array.public static void printLongArrayNoZero(long[] paraLongArray)
paraLongArray - The given long array.public static void printAllReducts(boolean[][] paraAllReducts)
paraAllReducts - The given array to print.public static void printBooleanArray(boolean[] paraBooleanArray)
public static void printBooleanMatrix(boolean[][] paraBooleanMatrix)
public static void printDoubleArray(double[] paraDoubleArray)
public static void swap(double[] paraDoubleArray,
int src,
int dest)
throws java.lang.Exception
paraDoubleArray - The given double array.src - The first index of the double array.dest - The second index of the double array.java.lang.Exception
public static void swap(long[] paraLongArray,
int src,
int dest)
throws java.lang.Exception
paraLongArray - The given long array.src - The first index of the long array.dest - The second index of the long array.java.lang.Exception
public static void swap(int[] paraLongArray,
int src,
int dest)
throws java.lang.Exception
paraLongArray - The given long array.src - The first index of the long array.dest - The second index of the long array.java.lang.Exception
public static boolean[][] longArrayToBooleanMatrix(long[] paraLongArray,
int paraLength)
paraLongArray - The given long array.paraLength - The length of each long.
public static boolean isSubset(long paraFirstSet,
long paraSecondSet,
int paraAttributes)
throws java.lang.Exception
paraFirstSet - The first set in long.paraSecondSet - The second set in long.paraAttributes - Number of attributes.java.lang.Exception
public static boolean isSubset(int[] paraFirstSet,
int[] paraSecondSet)
throws java.lang.Exception
paraFirstSet - The first set in int array.paraSecondSet - The second set in int array.java.lang.Exception
public static boolean isSubset(boolean[] paraFirstSet,
boolean[] paraSecondSet)
throws java.lang.Exception
paraFirstSet - The first set in boolean array.paraSecondSet - The second set in boolean array.java.lang.Exceptionpublic static java.lang.String longToBitString(long paraLong)
paraLong - The given long value.public static int getSubsetSize(boolean[] paraSubset)
paraSubset - A subset with the form of a boolean array.public static int getSubsetSize(long paraSubset)
paraSubset - A subset with the form of a long.
public static char subSetCheck(long paraFirstSet,
long paraSecondSet,
int paraNumberOfConditions)
paraFirstSet - the first set in long.paraSecondSet - the second set in long.paraNumberOfConditions - the number of conditions.public static java.lang.String booleanMatrixToString(boolean[][] tempMatrix)
public static boolean[] generateBooleanArrayForDivision(int paraDatasetSize,
double paraPercentage)
throws java.lang.Exception
paraDatasetSize - the dataset sizeparaPercentage - the percentage of the first subsetjava.lang.Exceptionpublic static boolean[] revertBooleanArray(boolean[] paraArray)
paraArray - the given array
public static long[] removeSupersets(long[] paraSets,
int paraNumberOfConditions)
throws java.lang.Exception
paraSets - the subsets with each one represented by a long value.paraNumberOfConditions - the number of condition of the datasetjava.lang.Exception
public static int[] setIntersection(int[] paraFirstSet,
int[] paraSecondSet)
throws java.lang.Exception
paraFirstSet - The first set indicated by numbers for indices.paraSecondSet - The second set indicated by numbers for indices.java.lang.Exceptionpublic static boolean isAscendingOrder(int[] paraArray)
paraArray - The int array.public static boolean isUpperTriangleBooleanMatrix(boolean[][] paraMatrix)
paraMatrix - The given boolean matrix.public static void main(java.lang.String[] args)
args -
|
|||||||||
| 上一个类 下一个类 | 框架 无框架 | ||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | ||||||||