Tabnine Logo
Collections.min
Code IndexAdd Tabnine to your IDE (free)

How to use
min
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.min (Showing top 20 results out of 3,168)

Refine searchRefine arrow

  • Collections.max
origin: stackoverflow.com

 import java.util.Arrays;
import java.util.Collections;

import org.apache.commons.lang.ArrayUtils;

public class MinMaxValue {

  public static void main(String[] args) {
    char[] a = {'3', '5', '1', '4', '2'};

    List b = Arrays.asList(ArrayUtils.toObject(a));

    System.out.println(Collections.min(b));
    System.out.println(Collections.max(b));
  }
}
origin: jersey/jersey

  public boolean contains(List<Integer> data) {
    if (Collections.min(data) < lower()
        || Collections.max(data) > upper()) {
      return false;
    } else {
      return true;
    }
  }
}
origin: apache/kylin

private void setupMapper(CubeSegment cubeSeg) throws IOException {
  // set the segment's offset info to job conf
  Map<Integer, Long> offsetStart = cubeSeg.getSourcePartitionOffsetStart();
  Map<Integer, Long> offsetEnd = cubeSeg.getSourcePartitionOffsetEnd();
  Integer minPartition = Collections.min(offsetStart.keySet());
  Integer maxPartition = Collections.max(offsetStart.keySet());
  job.getConfiguration().set(CONFIG_KAFKA_PARITION_MIN, minPartition.toString());
  job.getConfiguration().set(CONFIG_KAFKA_PARITION_MAX, maxPartition.toString());
  for(Integer partition: offsetStart.keySet()) {
    job.getConfiguration().set(CONFIG_KAFKA_PARITION_START + partition, offsetStart.get(partition).toString());
    job.getConfiguration().set(CONFIG_KAFKA_PARITION_END + partition, offsetEnd.get(partition).toString());
  }
  job.setMapperClass(KafkaFlatTableMapper.class);
  job.setInputFormatClass(KafkaInputFormat.class);
  job.setOutputKeyClass(BytesWritable.class);
  job.setOutputValueClass(Text.class);
  job.setOutputFormatClass(SequenceFileOutputFormat.class);
  job.setNumReduceTasks(0);
}
origin: FudanNLP/fnlp

public ArrayList<Integer> normalized(WDataSet wds){
  ArrayList<Integer> wNormalized = new ArrayList<Integer>();
  double max, min, wNDouble;
  int i, wNormalInt;
  double wNormal;
  max = Collections.max(wds.w);
  min = Collections.min(wds.w);
  
  if(max != min)
    for(i = 0; i < wds.graph.getNVerts(); i++){
      wNDouble = wds.w.get(i);
      wNormal = (wNDouble - min) / (max - min);
      wNormalInt = (int)(100 * wNormal);
      wds.w.set(i, wNormal);
      wNormalized.add(wNormalInt);
    }
  else
    for(i = 0; i < wds.graph.getNVerts(); i++)
      wNormalized.add(100);
  return wNormalized;
}
 
origin: Graylog2/graylog2-server

private void fillEmptyTimestamps(Map<Long, Map<String, Number>> results) {
  final long minTimestamp = Collections.min(results.keySet());
  final long maxTimestamp = Collections.max(results.keySet());
  final MutableDateTime currentTime = new MutableDateTime(minTimestamp, DateTimeZone.UTC);
  while (currentTime.getMillis() < maxTimestamp) {
    final Map<String, Number> entry = results.get(currentTime.getMillis());
    // advance timestamp by the interval
    currentTime.add(interval.getPeriod());
    if (entry == null) {
      // synthesize a 0 value for this timestamp
      results.put(currentTime.getMillis(), EMPTY_RESULT);
    }
  }
}
origin: jersey/jersey

final int i = data.indexOf(Collections.min(data));
g.setColor(minColor);
g.fillRect(xs[i] - step / 2, ys[i] - step / 2, step, step);
final int i = data.indexOf(Collections.max(data));
g.setColor(maxColor);
g.fillRect(xs[i] - step / 2, ys[i] - step / 2, step, step);
origin: cucumber/cucumber-jvm

  public byte exitStatus() {
    if (results.isEmpty()) { return DEFAULT; }

    if (runtimeOptions.isWip()) {
      return min(results, SEVERITY).is(Result.Type.PASSED) ? ERRORS : DEFAULT;
    }

    return max(results, SEVERITY).isOk(runtimeOptions.isStrict()) ? DEFAULT : ERRORS;
  }
}
origin: florent37/CameraFragment

Size maxPictureSize = Collections.max(choices, new CompareSizesByArea2());
Size minPictureSize = Collections.min(choices, new CompareSizesByArea2());
origin: florent37/CameraFragment

Size maxPictureSize = Collections.max(choices, new CompareSizesByArea2());
Size minPictureSize = Collections.min(choices, new CompareSizesByArea2());
origin: apache/hbase

private  ResultScanner scan(Table ht, byte[] cf,
  Integer[] rowIndexes, Integer[] columnIndexes,
  Long[] versions, int maxVersions)
throws IOException {
 Arrays.asList(rowIndexes);
 byte startRow[] = Bytes.toBytes("row:" +
   Collections.min( Arrays.asList(rowIndexes)));
 byte endRow[] = Bytes.toBytes("row:" +
   Collections.max( Arrays.asList(rowIndexes))+1);
 Scan scan = new Scan(startRow, endRow);
 for (Integer colIdx: columnIndexes) {
  byte column[] = Bytes.toBytes("column:" + colIdx);
  scan.addColumn(cf, column);
 }
 scan.setMaxVersions(maxVersions);
 scan.setTimeRange(Collections.min(Arrays.asList(versions)),
   Collections.max(Arrays.asList(versions))+1);
 ResultScanner scanner = ht.getScanner(scan);
 return scanner;
}
origin: gocd/gocd

private PipelineInstanceModels loadHistory(String pipelineName, List<Long> ids) {
  if (ids.isEmpty()) {
    return PipelineInstanceModels.createPipelineInstanceModels();
  }
  Map<String, Object> args = arguments("pipelineName", pipelineName)
      .and("from", Collections.min(ids))
      .and("to", Collections.max(ids)).asMap();
  PipelineInstanceModels history = PipelineInstanceModels.createPipelineInstanceModels(
      (List<PipelineInstanceModel>) getSqlMapClientTemplate().queryForList("getPipelineHistoryByName", args));
  for (PipelineInstanceModel pipelineInstanceModel : history) {
    loadPipelineHistoryBuildCause(pipelineInstanceModel);
  }
  return history;
}
origin: gocd/gocd

@SuppressWarnings("unchecked")
private List<Map<String, Object>> flatHistory(IBatisUtil.IBatisArgument arguments) {
  List<Long> pipelineIds = getSqlMapClientTemplate().queryForList("limitedPipelineIds", arguments.asMap());
  arguments.and("limitedPipelineIds", pipelineIds);
  long maxId = Collections.max(pipelineIds);
  long minId = Collections.min(pipelineIds);
  arguments = arguments.and("maxId", maxId).and("minId", minId);
  return (List<Map<String, Object>>) getSqlMapClientTemplate()
      .queryForList("getAllPropertiesHistory", arguments.asMap());
}
origin: googlesamples/android-Camera2Basic

  return Collections.min(bigEnough, new CompareSizesByArea());
} else if (notBigEnough.size() > 0) {
  return Collections.max(notBigEnough, new CompareSizesByArea());
} else {
  Log.e(TAG, "Couldn't find any suitable preview size");
origin: apache/hbase

/**
 * Uses the TimestampFilter on a Get to request a specified list of
 * versions for the row/column specified by rowIdx & colIdx.
 *
 */
private  Cell[] getNVersions(Table ht, byte[] cf, int rowIdx,
  int colIdx, List<Long> versions)
throws IOException {
 byte row[] = Bytes.toBytes("row:" + rowIdx);
 byte column[] = Bytes.toBytes("column:" + colIdx);
 Get get = new Get(row);
 get.addColumn(cf, column);
 get.setMaxVersions();
 get.setTimeRange(Collections.min(versions), Collections.max(versions)+1);
 Result result = ht.get(get);
 return result.rawCells();
}
origin: stackoverflow.com

versions.add(new Version("1.01.0"));
versions.add(new Version("1.00.1"));
Collections.min(versions).get() // return min version
Collections.max(versions).get() // return max version
origin: guoguibing/librec

maxRate = Collections.max(ratingScale);
minRate = Collections.min(ratingScale);
if (minRate == maxRate) {
  minRate = 0;
origin: stackoverflow.com

List<Integer> list = Arrays.asList(100,2,3,4,5,6,7,67,2,32);
 int min = Collections.min(list);
 int max = Collections.max(list);
 System.out.println(min);
 System.out.println(max);
origin: yahoo/egads

/**
 * Drops as many of the highest or lowest values as possible, leaving
 * at least one value in the list.
 * @param accumulator A non-null accumulator list.
 * @param count A count of 1 or more.
 * @param highest Drop higher values == true or drop lower values == false.
 */
public static void drop(final List<WeightedValue> accumulator, 
    final int count, final boolean highest) {
  for (int x = 0; x < count; x++) {
    if (accumulator.size() <= 1) {
      break;
    }
    if (highest) {
      accumulator.remove(Collections.max(accumulator));
    } else {
      accumulator.remove(Collections.min(accumulator));
    }
  }
}

origin: yahoo/egads

/**
 * Creates a histogram of the provided data.
 * 
 * @param data list of observations
 * @param breaks number of breaks in the histogram
 * @return List of integer values size of the breaks
 */
public static List<Integer> getHistogram(List<Double> data, int breaks) {
  if (data.isEmpty()) {
    return Collections.emptyList();
  }
  List<Integer> ret = new ArrayList<Integer>(breaks);
  for (int i = 0; i < breaks; i++) {
    ret.add(0);
  }
  double min = Collections.min(data);
  double range = Collections.max(data) - min + 1;
  double step = range / breaks;
  for (double point : data) {
    // Math.min necessary because rounding error -> AIOOBE
    int index = Math.min((int) ((point - min) / step), breaks - 1);
    ret.set(index, ret.get(index) + 1);
  }
  return ret;
}

origin: yahoo/egads

/**
 * Same as <code>getHistogram</code> but operates on <code>BigIntegers</code>.
 */
public static List<Integer> getHistogramBigInt(List<BigInteger> data, int breaks) {
  if (data.isEmpty()) {
    return Collections.emptyList();
  }
  List<Integer> ret = new ArrayList<Integer>(breaks);
  for (int i = 0; i < breaks; i++) {
    ret.add(0);
  }
  BigInteger min = Collections.min(data);
  BigInteger max = Collections.max(data);
  BigInteger range = max.subtract(min).add(BigInteger.valueOf(1));
  BigInteger step = range.divide(BigInteger.valueOf(breaks));
  if (step.equals(BigInteger.ZERO)) {
    return Collections.emptyList(); // too small
  }
  for (BigInteger point : data) {
    int index = point.subtract(min).divide(step).intValue();
    // Math.min necessary because rounding error -> AIOOBE
    index = Math.min(index, breaks - 1);
    ret.set(index, ret.get(index) + 1);
  }
  return ret;
}

java.utilCollectionsmin

Javadoc

Searches the specified collection for the minimum element.

Popular methods of Collections

  • emptyList
    Returns the empty list (immutable). This list is serializable.This example illustrates the type-safe
  • sort
  • singletonList
    Returns an immutable list containing only the specified object. The returned list is serializable.
  • unmodifiableList
    Returns an unmodifiable view of the specified list. This method allows modules to provide users with
  • emptyMap
    Returns the empty map (immutable). This map is serializable.This example illustrates the type-safe w
  • emptySet
    Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this metho
  • unmodifiableMap
    Returns an unmodifiable view of the specified map. This method allows modules to provide users with
  • singleton
    Returns an immutable set containing only the specified object. The returned set is serializable.
  • unmodifiableSet
    Returns an unmodifiable view of the specified set. This method allows modules to provide users with
  • singletonMap
    Returns an immutable map, mapping only the specified key to the specified value. The returned map is
  • addAll
    Adds all of the specified elements to the specified collection. Elements to be added may be specifie
  • reverse
    Reverses the order of the elements in the specified list. This method runs in linear time.
  • addAll,
  • reverse,
  • unmodifiableCollection,
  • shuffle,
  • enumeration,
  • list,
  • synchronizedMap,
  • synchronizedList,
  • reverseOrder,
  • emptyIterator

Popular in Java

  • Making http requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now