|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgr.demokritos.iit.jinsect.utils
public final class utils
A class including a set of useful, general purpose functions.
Constructor Summary | |
---|---|
utils()
|
Method Summary | |
---|---|
static double |
abs(double dNum)
Math.abs reimplemented. |
static void |
bubbleSortArray(java.lang.Comparable[] aArr)
Bubble-sorts an array of comparable items. |
static java.util.List |
bubbleSortVerticesByStringLength(java.util.List l)
Bubble sorts the strings in a given String list, where the longest string is the first checked. |
static double |
factorial(int n)
Returns the factorial |
static double |
factorial(int m,
int n)
Returns the factorial |
static java.util.List |
getAdjacentIncomingVertices(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vTail)
Gets the adjacent vertices of incoming edges of a given vertex in a directed graph. |
static Union |
getCombinationsBy(java.lang.Object oObj,
int iBySize)
Creates a Union of combinations of elements taken from a given list for a given number
of elements per combined set. |
static int |
getConstructor(java.lang.String sClassName,
int iParams)
Returns the index of the constructor of a class, given its parameter count. |
static java.lang.String |
getFilenameOnly(java.lang.String sFilepath)
Returns the portion of filename after the last directory separator. |
double |
getHistogramTotal(java.util.HashMap hHist)
|
static java.util.List |
getIncomingEdges(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vTail)
Gets the incoming edges to a given vertex in a directed graph. |
static java.util.List |
getOutgoingAdjacentVertices(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vHead)
Gets the adjacent vertices of outgoing edges from a given vertex in a graph. |
static java.util.List |
getOutgoingEdges(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vHead)
Gets the outgoing edges of a given vertex in a graph. |
static Union |
getSubStrings(java.lang.String sStr,
int iMaxSubStringSize,
IMatching isMatcher)
Calculates the substrings matching particular requirements in a given string, given a maximum substring size. |
static Union |
getSubStrings(java.lang.String sStr,
int iMaxSubStringSize,
IMatching isMatcher,
int iMaxDepth)
Calculates the substrings matching particular requirements in a given string, given a maximum substring size. |
static Union |
getSubStrings(java.lang.String sStr,
int iMaxSubStringSize,
IMatching isMatcher,
int iMaxDepth,
int iCurDepth)
Helper function. |
static java.lang.String |
getSwitch(java.util.Hashtable hSwitches,
java.lang.String sOption,
java.lang.String sDefault)
Given a Hashtable and a given option string, this function returns either the
option set in the hashtable, or a given default if the option has not been set. |
static java.lang.String |
getSystemEncoding()
Returns the system encoding String. |
static java.lang.String |
graphToDot(UniqueVertexGraph gTree,
boolean bDirected)
Renders a graph to its DOT representation (See GraphViz for more info on the format). |
static java.lang.String |
graphToDot(UniqueVertexGraph gTree,
boolean bDirected,
java.util.Map hEdgeDistros)
Renders a graph to its DOT representation (See GraphViz for more info on the format). |
static java.lang.String |
loadFileSetToString(java.util.Set<java.lang.String> ssFiles)
Loads the contents of a set of files into a string, by calling repeatedly loadFileToString . |
static java.lang.String |
loadFileSetToString(java.util.Set<java.lang.String> ssFiles,
IFileLoader<java.lang.String> lLoader)
Loads the contents of a set of files into a string, by calling repeatedly the loadFile function of a IFileLoader . |
static java.lang.String |
loadFileToString(java.lang.String sFilename)
Loads the contents of a file into a string, without preserving newlines. |
static java.lang.String |
loadFileToString(java.lang.String sFilename,
int iMaxLen)
Loads the contents of a file into a string, without preserving newlines. |
static java.lang.String |
loadFileToStringWithNewlines(java.lang.String sFilename)
Loads the contents of a file into a string, preserving newlines. |
static salvo.jesus.graph.Edge |
locateDirectedEdgeInGraph(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vHead,
salvo.jesus.graph.Vertex vTail)
Looks up a given directed edge in a selected graph. |
static salvo.jesus.graph.Edge |
locateEdgeInGraph(UniqueVertexGraph gGraph,
java.lang.String sHead,
java.lang.String sTail)
Looks up a given (undirected) edge in a selected graph. |
static salvo.jesus.graph.Edge |
locateEdgeInGraph(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vHead,
salvo.jesus.graph.Vertex vTail)
Looks up a given (undirected) edge in a selected graph. |
static salvo.jesus.graph.Vertex |
locateVertexInGraph(UniqueVertexGraph gGraph,
java.lang.String sToFind)
Looks up a vertex, based on its label, within a given graph. |
static salvo.jesus.graph.Vertex |
locateVertexInGraph(UniqueVertexGraph gGraph,
salvo.jesus.graph.Vertex vToFind)
Looks up a vertex in a given graph. |
static double |
logX(double dNumber,
double dBase)
Calculates the logarithm of a number using a given base. |
static void |
main(java.lang.String[] args)
Testbench function. |
static double |
max(double Num1,
double Num2)
Math.max reimplemented. |
static java.lang.String |
millisToMinSecString(long lMillis)
Converts milliseconds to a string representation of x hours, y min, z sec. |
static double |
min(double Num1,
double Num2)
Math.min reimplemented. |
static java.util.Hashtable |
parseCommandLineSwitches(java.lang.String[] sCommands)
Parses the command line expecting values of either `-switch` or `-key=value` and returns corresponding Hashtable , with switches as keys
and `TRUE` as value, or `key` as keys and `value` as values |
static java.lang.String |
printIterable(java.lang.Iterable iIterable,
java.lang.String sSeparator)
Creates a formatted string representation of an iterable object using a given separator. |
static java.lang.String |
printList(java.util.List lToPrint)
Creates a formatted string representation of a (possibly nested) list, taking into account Union and
Concatenation objects. |
static java.lang.String |
printList(java.util.List lToPrint,
java.lang.String sSeparator)
Creates a formatted string representation of a (possibly nested) list, taking into account Union and
Concatenation objects and using a given separator. |
static java.lang.String |
printSortIterable(java.lang.Iterable iIterable,
java.lang.String sSeparator)
Creates a formatted string representation of an iterable object, sorting the string representation of its parts at the output. |
static java.lang.String |
repeatString(java.lang.String sStr,
int iTimes)
Repeats a given string a specified number of times. |
static java.util.List |
reverseList(java.util.List l)
Returns a reversed (by means of item index) version of a given list. |
static void |
shuffleList(java.util.List l)
Randomizes the order of items in a given list. |
static double |
sign(double dNum)
The sign function. |
static java.lang.String[] |
splitToWords(java.lang.String sStr)
Splits a given string to its words, without stemming. |
static java.lang.String[] |
splitToWords(java.lang.String sStr,
boolean bStem)
Splits a given string to its words, without stemming. |
static int |
sumFromTo(int iStart,
int iEnd)
Returns the sum of a sequence of numbers in a specified range |
static java.lang.String |
toUTF8(java.lang.String sStr)
Converts a string to UTF-8 encoding. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public utils()
Method Detail |
---|
public static final double max(double Num1, double Num2)
public static final double min(double Num1, double Num2)
public static final double abs(double dNum)
public static final salvo.jesus.graph.Edge locateEdgeInGraph(UniqueVertexGraph gGraph, java.lang.String sHead, java.lang.String sTail)
gGraph
- The graph to use.sHead
- The label of the head or tail vertex of the edge.sTail
- The label of the tail or tail vertex of the edge.
public static final salvo.jesus.graph.Vertex locateVertexInGraph(UniqueVertexGraph gGraph, java.lang.String sToFind)
gGraph
- The graph to use.sToFind
- The label of the desired vertex.
public static final salvo.jesus.graph.Vertex locateVertexInGraph(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vToFind)
gGraph
- The graph to use.vToFind
- The vertex to locate.
public static final salvo.jesus.graph.Edge locateEdgeInGraph(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vHead, salvo.jesus.graph.Vertex vTail)
gGraph
- The graph to use.vHead
- A vertex with the desired label for the head or tail of the edge.vTail
- A vertex with the desired label for the tail or tail of the edge.
public static final salvo.jesus.graph.Edge locateDirectedEdgeInGraph(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vHead, salvo.jesus.graph.Vertex vTail)
gGraph
- The graph to use.vHead
- A vertex with the desired label for the head of the edge.vTail
- A vertex with the desired label for the tail of the edge.
public static final java.util.List getOutgoingEdges(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vHead)
gGraph
- The graph to use.vHead
- A vertex with the desired label for the head of the edge.
vHead
. If no such edges exist returns an
empty list.public static final java.util.List getOutgoingAdjacentVertices(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vHead)
gGraph
- The graph to use.vHead
- A vertex with the desired label for the head of the edge.
public static final java.util.List getIncomingEdges(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vTail)
gGraph
- The graph to use.vTail
- A vertex with the desired label for the tail of the edge.
vTail
. If no such edges exist returns an
empty list.public static final java.util.List getAdjacentIncomingVertices(UniqueVertexGraph gGraph, salvo.jesus.graph.Vertex vTail)
gGraph
- The graph to use.vTail
- A vertex with the desired label for the tail of the edge.
vTail
. If no such edges exist returns an
empty list.public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public static final java.lang.String millisToMinSecString(long lMillis)
lMillis
- The long number of milliseconds.
public static final void shuffleList(java.util.List l)
l
- The input list that will be modified.public static final java.lang.String[] splitToWords(java.lang.String sStr)
sStr
- The input string.
public static final java.lang.String[] splitToWords(java.lang.String sStr, boolean bStem)
sStr
- The input string.bStem
- True if stemming should be performed to the input words, otherwise false.
public static final double logX(double dNumber, double dBase)
dNumber
- The number whose logarithm is meant to be calculated.dBase
- The base of the logarithm.
dBase
of dNumber
.public static final java.lang.String printSortIterable(java.lang.Iterable iIterable, java.lang.String sSeparator)
iIterable
- The iterable object.sSeparator
- The separator to use for elements.
public static final java.lang.String printIterable(java.lang.Iterable iIterable, java.lang.String sSeparator)
iIterable
- The (possibly nested) iterable object.sSeparator
- The separator to use for elements of the same level.
public static final java.lang.String printList(java.util.List lToPrint, java.lang.String sSeparator)
Union
and
Concatenation
objects and using a given separator.
lToPrint
- The (possibly nested) list.sSeparator
- The separator to use for elements of the same level.
public static final java.lang.String printList(java.util.List lToPrint)
Union
and
Concatenation
objects.
lToPrint
- The (possibly nested) list.
public static final Union getCombinationsBy(java.lang.Object oObj, int iBySize)
Union
of combinations of elements taken from a given list for a given number
of elements per combined set.
oObj
- The input list.iBySize
- The size of elements to use in every combination returned.
Union
of combination alternatives.public static final Union getSubStrings(java.lang.String sStr, int iMaxSubStringSize, IMatching isMatcher)
sStr
- The input string.iMaxSubStringSize
- The maximum substring size to take into account.isMatcher
- A matcher of type IMatching
to use, in order to take into account
a given substring or not.
Union
of the matched substrings within the given string.public static final Union getSubStrings(java.lang.String sStr, int iMaxSubStringSize, IMatching isMatcher, int iMaxDepth)
sStr
- The input string.iMaxSubStringSize
- The maximum substring size to take into account.isMatcher
- A matcher of type IMatching
to use, in order to take into account
a given substring or not.iMaxDepth
- The maximum depth of analysis to use for the substring analysis.
Union
of the matched substrings within the given string.public static final Union getSubStrings(java.lang.String sStr, int iMaxSubStringSize, IMatching isMatcher, int iMaxDepth, int iCurDepth)
sStr
- The input string.iMaxSubStringSize
- The maximum substring size to take into account.isMatcher
- A matcher of type IMatching
to use, in order to take into account
a given substring or not.iMaxDepth
- The maximum depth of analysis to use for the substring analysis.iCurDepth
- The current reached depth.
Union
of the matched substrings within the given string.public static java.lang.String getSystemEncoding()
public static java.lang.String toUTF8(java.lang.String sStr)
sStr
- The input string.
public static double sign(double dNum)
dNum
- The input number.
public static final void bubbleSortArray(java.lang.Comparable[] aArr)
aArr
- An array of Comparable
objects.public static final java.util.List bubbleSortVerticesByStringLength(java.util.List l)
l
- The input list.
public static java.util.Hashtable parseCommandLineSwitches(java.lang.String[] sCommands)
Hashtable
, with switches as keys
and `TRUE` as value, or `key` as keys and `value` as values
sCommands
- The command line array of Strings.
public static java.lang.String getSwitch(java.util.Hashtable hSwitches, java.lang.String sOption, java.lang.String sDefault)
Hashtable
and a given option string, this function returns either the
option set in the hashtable, or a given default if the option has not been set.
hSwitches
- The hashtable of switches (see also parseCommandLineSwitches
).sOption
- The name of the option of interest.sDefault
- The default value to be used if the option has not been set.
public static int sumFromTo(int iStart, int iEnd)
iStart
- The minimum term of the sequenceiEnd
- The maximum term of the sequencepublic double getHistogramTotal(java.util.HashMap hHist)
public static java.lang.String graphToDot(UniqueVertexGraph gTree, boolean bDirected)
gTree
- The input graph.bDirected
- Indicate whether the graph should be described as a directed graph or not.
public static java.lang.String graphToDot(UniqueVertexGraph gTree, boolean bDirected, java.util.Map hEdgeDistros)
gTree
- The input graph.bDirected
- Indicate whether the graph should be described as a directed graph or not.hEdgeDistros
- The map between edges and their distributions
public static java.lang.String loadFileToString(java.lang.String sFilename)
sFilename
- The filename of the file to load.
public static java.lang.String loadFileToString(java.lang.String sFilename, int iMaxLen)
sFilename
- The filename of the file to load.
public static java.lang.String loadFileToStringWithNewlines(java.lang.String sFilename)
sFilename
- The filename of the file to load.
public static java.lang.String loadFileSetToString(java.util.Set<java.lang.String> ssFiles)
loadFileToString
. Each file is separated from another by a
zero character (char(0)).
ssFiles
- The set of string filenames to load.
public static java.lang.String loadFileSetToString(java.util.Set<java.lang.String> ssFiles, IFileLoader<java.lang.String> lLoader)
loadFile
function of a IFileLoader
.
Each file is separated from another by a zero character (char(0)).
ssFiles
- The set of string filenames to load.lLoader
- The loader to use for loading the files
public static final java.lang.String repeatString(java.lang.String sStr, int iTimes)
sStr
- The string to repeat.iTimes
- The times to repeat the string.
public static final double factorial(int n)
1*2*...*(n-1)*n.
n
- The highest number of the factorial.
public static final double factorial(int m, int n)
m*(m+1)*...*(n-1)*n.
m
- The lowest number of the factorial.n
- The highest number of the factorial.
public static java.util.List reverseList(java.util.List l)
l
- The list to reverse.
public static final java.lang.String getFilenameOnly(java.lang.String sFilepath)
sFilepath
- The path to the file.
public static final int getConstructor(java.lang.String sClassName, int iParams)
sClassName
- The class name of interest.iParams
- The parameter count to look for.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |