id stringlengths 24 24 | input stringlengths 58 605 | output stringlengths 57 725 |
|---|---|---|
636767601a6d9265ec0180e2 | /**
* Computes the global separator list of the {@code graph}. More precisely, for every edge $e$ in the $G = (V, E)$ computes list of minimal separators $S_e$ in the neighborhood of $e$ and then concatenates these lists. Note: the result may contain duplicates
* @return the list of minimal separators of every edge... | private List<Pair<List<Pair<Integer,Integer>>,E>> computeGlobalSeparatorList(){
List<Pair<List<Pair<Integer,Integer>>,E>> globalSeparatorList=new ArrayList<>();
for ( E edge : graph.edgeSet()) {
V source=graph.getEdgeSource(edge);
V target=graph.getEdgeTarget(edge);
if (source != target) {
List<S... |
636766f31a6d9265ec01768f | /**
* <p>Clones an array returning a typecast result and handling <code>null</code>.</p> <p>This method returns <code>null</code> for a <code>null</code> input array.</p>
* @param array the array to clone, may be <code>null</code>
* @return the cloned array, <code>null</code> if <code>null</code> input
*/
public ... | public static char[] clone(final char[] array){
if (array == null) {
return null;
}
return array.clone();
}
|
636766831a6d9265ec0174eb | /**
* Add the specified files in reverse order.
*/
private void addReverse(final File[] files){ | private void addReverse(final File[] files){
if (files == null) return;
for (int i=files.length - 1; i >= 0; --i) {
stack.add(files[i]);
}
}
|
636767841a6d9265ec0183ff | /**
* Selects a the specified row in the specified JTable and scrolls the specified JScrollpane to the newly selected row. More importantly, the call to repaint() delayed long enough to have the table properly paint the newly selected row which may be offscre
* @param table should belong to the specified JScrollPane... | public static void selectRow(int row,JTable table,JScrollPane pane){
if (table == null || pane == null) {
return;
}
if (contains(row,table.getModel()) == false) {
return;
}
moveAdjustable(row * table.getRowHeight(),pane.getVerticalScrollBar());
selectRow(row,table.getSelectionModel());
repaintLate... |
636766a81a6d9265ec017596 | /**
* Puts an int into this byte vector. The byte vector is automatically enlarged if necessary.
* @param intValue an int.
* @return this byte vector.
*/
public ByteVector putInt(final int intValue){ | public ByteVector putInt(final int intValue){
int currentLength=length;
if (currentLength + 4 > data.length) {
enlarge(4);
}
byte[] currentData=data;
currentData[currentLength++]=(byte)(intValue >>> 24);
currentData[currentLength++]=(byte)(intValue >>> 16);
currentData[currentLength++]=(byte)(intValue... |
636766fd1a6d9265ec017814 | /**
* Compares <code>count</code> first bytes in the arrays <code>a</code> and <code>b</code>.
* @param a The first array to compare.
* @param b The second array to compare.
* @param count How many bytes should be compared.
* @return <code>true</code> if <code>count</code> first bytes in arrays<code>a</co... | public static boolean arrayequals(byte[] a,byte[] b,int count){
for (int i=0; i < count; i++) {
if (a[i] != b[i]) {
return false;
}
}
return true;
}
|
636767861a6d9265ec018440 | /**
* Abbreviate name.
* @param buf buffer to append abbreviation.
* @param nameStart start of name to abbreviate.
*/
public void abbreviate(final int nameStart,final StringBuffer buf){ | public void abbreviate(final int nameStart,final StringBuffer buf){
int i=count;
for (int pos=buf.indexOf(".",nameStart); pos != -1; pos=buf.indexOf(".",pos + 1)) {
if (--i == 0) {
buf.delete(nameStart,pos + 1);
break;
}
}
}
|
6367667d1a6d9265ec01741d | /**
* Resolves the first bound for the {@code typeVariable}, returning {@code Unknown.class} if nonecan be resolved.
*/
public static Type resolveBound(TypeVariable<?> typeVariable){ | public static Type resolveBound(TypeVariable<?> typeVariable){
Type[] bounds=typeVariable.getBounds();
if (bounds.length == 0) return Unknown.class;
Type bound=bounds[0];
if (bound instanceof TypeVariable) bound=resolveBound((TypeVariable<?>)bound);
return bound == Object.class ? Unknown.class : bound;
}
|
6367675f1a6d9265ec0180cf | /**
* Check whether the subgraph of <code>graph</code> induced by the given <code>vertices</code> is complete, i.e. a clique.
* @param graph the graph.
* @param vertices the vertices to induce the subgraph from.
* @return true if the induced subgraph is a clique.
*/
private static <V,E>boolean isClique(Graph<V,E>... | private static <V,E>boolean isClique(Graph<V,E> graph,Set<V> vertices){
for ( V v1 : vertices) {
for ( V v2 : vertices) {
if (!v1.equals(v2) && (graph.getEdge(v1,v2) == null)) {
return false;
}
}
}
return true;
}
|
636767431a6d9265ec017c88 | /**
* Finds a maximum lower bound for every key.
* @param keys list of keys.
* @return the computed key lower bounds.
*/
private List<Integer> computeLowerBounds(List<K> keys){ | private List<Integer> computeLowerBounds(List<K> keys){
List<Integer> keyLowerBounds=new ArrayList<>(keys.size());
for ( K key : keys) {
int lowerBound=0;
for ( Function<K,Integer> lowerBoundFunction : lowerBounds) {
lowerBound=Math.max(lowerBound,lowerBoundFunction.apply(key));
}
keyLower... |
636766a91a6d9265ec0175c4 | /**
* Pops as many abstract types from the output frame stack as described by the given descriptor.
* @param descriptor a type or method descriptor (in which case its argument types are popped).
*/
private void pop(final String descriptor){ | private void pop(final String descriptor){
char firstDescriptorChar=descriptor.charAt(0);
if (firstDescriptorChar == '(') {
pop((Type.getArgumentsAndReturnSizes(descriptor) >> 2) - 1);
}
else if (firstDescriptorChar == 'J' || firstDescriptorChar == 'D') {
pop(2);
}
else {
pop(1);
}
}
|
636766fb1a6d9265ec0177c3 | /**
* <p>Checks whether the character is ASCII 7 bit.</p> <pre> CharUtils.isAscii('a') = true CharUtils.isAscii('A') = true CharUtils.isAscii('3') = true CharUtils.isAscii('-') = true CharUtils.isAscii('\n') = true CharUtils.isAscii('©') = false </pre>
* @param ch the character to check
* @return true if ... | public static boolean isAscii(final char ch){
return ch < 128;
}
|
636767581a6d9265ec017fb4 | /**
* Finds a minimum lower bound for every key.
* @param keys a list of keys.
* @return the computed key upper bound.
*/
private List<Integer> computeUpperBounds(List<K> keys){ | private List<Integer> computeUpperBounds(List<K> keys){
List<Integer> keyUpperBounds=new ArrayList<>(keys.size());
for ( K key : keys) {
int upperBound=Integer.MAX_VALUE;
for ( Function<K,Integer> upperBoundFunction : upperBounds) {
upperBound=Math.min(upperBound,upperBoundFunction.apply(key));
... |
636766801a6d9265ec017487 | /**
* Encodes a string with template parameters names present, specifically the characters '{' and '}' will be percent-encoded.
* @param s the string with zero or more template parameters names
* @return the string with encoded template parameters names.
*/
public static String encodeTemplateNames(String s){ | public static String encodeTemplateNames(String s){
int i=s.indexOf('{');
if (i != -1) s=s.replace("{","%7B");
i=s.indexOf('}');
if (i != -1) s=s.replace("}","%7D");
return s;
}
|
636767531a6d9265ec017ef1 | /**
* Compare two points for equality using tolerance 1e-9.
* @param p1 the first point
* @param p2 the second point
* @return whether the two points are equal or not
*/
public static boolean equals(Point2D p1,Point2D p2){ | public static boolean equals(Point2D p1,Point2D p2){
int xEquals=TOLERANCE_DOUBLE_COMPARATOR.compare(p1.getX(),p2.getX());
if (xEquals != 0) {
return false;
}
return TOLERANCE_DOUBLE_COMPARATOR.compare(p1.getY(),p2.getY()) == 0;
}
|
6367667c1a6d9265ec0173fb | /**
* Add a {@link AtmosphereResourceEventListener}.
* @param e an instance of AtmosphereResourceEventListener
*/
@Override public AtmosphereResource addEventListener(AtmosphereResourceEventListener e){ | @Override public AtmosphereResource addEventListener(AtmosphereResourceEventListener e){
if (listeners.contains(e)) return this;
listeners.add(e);
return this;
}
|
636767691a6d9265ec0181ac | /**
* Apply the given relative path to the given path, assuming standard Java folder separation (i.e. "/" separators).
* @param path the path to start from (usually a full file path)
* @param relativePath the relative path to apply(relative to the full file path above)
* @return the full file path that results fro... | public static String applyRelativePath(String path,String relativePath){
int separatorIndex=path.lastIndexOf(FOLDER_SEPARATOR);
if (separatorIndex != -1) {
String newPath=path.substring(0,separatorIndex);
if (!relativePath.startsWith(FOLDER_SEPARATOR)) {
newPath+=FOLDER_SEPARATOR;
}
return new... |
636767021a6d9265ec0178bc | /**
* Finds the first index within a String, handling <code>null</code>. This method uses {@link String#indexOf(String)}.
*/
public static int indexOf(String str,String searchStr){ | public static int indexOf(String str,String searchStr){
if (str == null || searchStr == null) {
return StringUtils.INDEX_NOT_FOUND;
}
return str.indexOf(searchStr);
}
|
636766fc1a6d9265ec0177ef | /**
* Returns a new array of Strings without null elements. Internal method used to normalize exclude lists (arrays and collections). Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException}if an array element is <code>null</code>.
* @param array The array to check
* @return The given arr... | static String[] toNoNullStringArray(Object[] array){
ArrayList<String> list=new ArrayList<String>(array.length);
for (int i=0; i < array.length; i++) {
Object e=array[i];
if (e != null) {
list.add(e.toString());
}
}
return (String[])list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
|
636767061a6d9265ec01794a | /**
* Returns the index of the last extension separator character, which is a dot. <p> This method also checks that there is no directory separator after the last dot. To do this it uses {@link #indexOfLastSeparator(String)} which willhandle a file in either Unix or Windows format. <p> The output will be the same ir... | public static int indexOfExtension(String filename){
if (filename == null) {
return -1;
}
int extensionPos=filename.lastIndexOf(EXTENSION_SEPARATOR);
int lastSeparator=indexOfLastSeparator(filename);
return lastSeparator > extensionPos ? -1 : extensionPos;
}
|
636767dd1a6d9265ec0186de | /**
* @param timestamp of current time
* @param expiredThreshold represents the duration between last update time and the time point removing from cache.
* @return true means this metrics should be removed from cache.
*/
public boolean isExpired(long timestamp,long expiredThreshold){ | public boolean isExpired(long timestamp,long expiredThreshold){
return timestamp - lastUpdateTimestamp > expiredThreshold;
}
|
6367675d1a6d9265ec018082 | /**
* Returns an edge connecting previously returned node with node, which will be returned next. If either of the mentioned nodes is virtual, the edge will be incident to its real counterpart.
* @return an edge from the current node to the next node
*/
Edge edgeToNext(){ | Edge edgeToNext(){
Edge edge=prev.embedded.getFirst();
Node target=toExistingNode(current);
Node source=toExistingNode(prev);
if (edge.getOpposite(source) == target) {
return edge;
}
else {
return prev.embedded.getLast();
}
}
|
6367676b1a6d9265ec0181e9 | /**
* Returns {@code true} if the given string matches the given substring at the given index, {@code false} otherwise.
* @param str the original string (or StringBuilder)
* @param index the index in the original string to start matching against
* @param substring the substring to match at the given index
* @ret... | public static boolean substringMatch(CharSequence str,int index,CharSequence substring){
for (int j=0; j < substring.length(); j++) {
int i=index + j;
if (i >= str.length() || str.charAt(i) != substring.charAt(j)) {
return false;
}
}
return true;
}
|
636767781a6d9265ec01823e | /**
* Handles a log event. For this appender, that means writing the message to each connected client.
*/
protected void append(LoggingEvent event){ | protected void append(LoggingEvent event){
if (sh != null) {
sh.send(layout.format(event));
if (layout.ignoresThrowable()) {
String[] s=event.getThrowableStrRep();
if (s != null) {
StringBuffer buf=new StringBuffer();
for (int i=0; i < s.length; i++) {
buf.append(s[i]);
... |
6367670b1a6d9265ec017a05 | /**
* <p>Converts the character to a String that contains the one character.</p> <p>For ASCII 7 bit characters, this uses a cache that will return the same String object each time.</p> <pre> CharUtils.toString(' ') = " " CharUtils.toString('A') = "A" </pre>
* @param ch the character to convert
* @return a String... | public static String toString(final char ch){
if (ch < 128) {
return CharUtils.CHAR_STRING_ARRAY[ch];
}
return new String(new char[]{ch});
}
|
636767a31a6d9265ec01854f | /**
* Check if this field have been packed into a length-delimited field. If so, update internal state to reflect that packed fields are being read.
* @throws IOException
*/
private void checkIfPackedField() throws IOException { | private void checkIfPackedField() throws IOException {
if (packedLimit == 0 && WireFormat.getTagWireType(lastTag) == WIRETYPE_LENGTH_DELIMITED) {
final int length=readRawVarint32();
if (length < 0) throw ProtobufException.negativeSize();
this.packedLimit=getTotalBytesRead() + length;
}
}
|
636767a81a6d9265ec0185fc | /**
* Attempt to read a field tag, returning zero if we have reached EOF. Protocol message parsers use this to read tags, since a protocol message may legally end wherever a tag occurs, and zero is not a valid tag number.
*/
public int readTag() throws IOException { | public int readTag() throws IOException {
if (!buffer.hasRemaining()) {
lastTag=0;
return 0;
}
final int tag=readRawVarint32();
if (tag >>> TAG_TYPE_BITS == 0) {
throw ProtobufException.invalidTag();
}
lastTag=tag;
return tag;
}
|
636766a81a6d9265ec017595 | /**
* Puts two bytes into this byte vector. The byte vector is automatically enlarged if necessary.
* @param byteValue1 a byte.
* @param byteValue2 another byte.
* @return this byte vector.
*/
final ByteVector put11(final int byteValue1,final int byteValue2){ | final ByteVector put11(final int byteValue1,final int byteValue2){
int currentLength=length;
if (currentLength + 2 > data.length) {
enlarge(2);
}
byte[] currentData=data;
currentData[currentLength++]=(byte)byteValue1;
currentData[currentLength++]=(byte)byteValue2;
length=currentLength;
return this;
... |
636766ae1a6d9265ec0175d8 | /**
* Build the 'Content-Range' HTTP Header value.
* @return 'Content-Range' value
*/
private String buildContentRange(){ | private String buildContentRange(){
Integer limit=drc.getLimit() == null ? getDefaultNumberPagination() - 1 : drc.getLimit();
Integer offset=drc.getOffset() == null ? 0 : drc.getOffset();
Long count=drc.getCount() == null ? 0 : drc.getCount();
return offset + "-" + (limit.equals(0) ? count - 1 : limit)+ "/"+ co... |
636767e11a6d9265ec018790 | /**
* load thread snapshots in appointing time range
*/
public static List<ThreadSnapshot> parseFromFileWithTimeRange(File file,List<ProfileAnalyzeTimeRange> timeRanges) throws IOException { | public static List<ThreadSnapshot> parseFromFileWithTimeRange(File file,List<ProfileAnalyzeTimeRange> timeRanges) throws IOException {
try (final FileInputStream fileInputStream=new FileInputStream(file)){
ThreadSnapshot snapshot;
final ArrayList<ThreadSnapshot> data=new ArrayList<>();
while ((snapshot=Th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.