本文整理汇总了Java中de.linearbits.objectselector.Selector.isSelected方法的典型用法代码示例。如果您正苦于以下问题:Java Selector.isSelected方法的具体用法?Java Selector.isSelected怎么用?Java Selector.isSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.linearbits.objectselector.Selector
的用法示例。
在下文中一共展示了Selector.isSelected方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Series3D
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Creates a series by selecting rows and taking three values
*
* @param file
* @param selector
* @param xField
* @param yField
* @param zField
*/
public Series3D(CSVFile file,
Selector<String[]> selector,
Field xField,
Field yField,
Field zField){
Iterator<CSVLine> iter = file.iterator();
while (iter.hasNext()) {
CSVLine csvline = iter.next();
String[] line = csvline.getData();
if (selector.isSelected(line)) {
String x = csvline.get(xField.category, xField.measure);
String y = csvline.get(yField.category, yField.measure);
String z = csvline.get(zField.category, zField.measure);
data.add(new Point3D(x, y, z));
}
}
}
示例2: Series2D
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Creates a series by selecting rows and taking two values
*
* @param file
* @param selector
* @param xField
* @param yField
*/
public Series2D(CSVFile file,
Selector<String[]> selector,
Field xField,
Field yField){
Iterator<CSVLine> iter = file.iterator();
while (iter.hasNext()) {
CSVLine csvline = iter.next();
String[] line = csvline.getData();
if (selector.isSelected(line)) {
String x = csvline.get(xField.category, xField.measure);
String y = csvline.get(yField.category, yField.measure);
data.add(new Point2D(x, y));
}
}
}
示例3: analyzeMean
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Analyzes the results from one experiment
* @param file
* @param measure
* @param suppression
* @param criterion
* @throws ParseException
*/
private static void analyzeMean(CSVFile file,
BenchmarkQualityMeasure measure,
double suppression,
BenchmarkPrivacyModel criterion) throws ParseException {
// Select
Selector<String[]> selector = file.getSelectorBuilder()
.field("Suppression limit").equals(String.valueOf(suppression)).and()
.field("Quality measure").equals(measure.toString()).and()
.field("Privacy model").equals(criterion.toString())
.build();
// Iterate
double lightning = 1d;
double datafly = 1d;
double igreedy = 1d;
for (Iterator<CSVLine> iter = file.iterator(); iter.hasNext(); ) {
CSVLine line = iter.next();
if (selector.isSelected(line.getData())) {
lightning *= Double.valueOf(line.get("Lightning", Analyzer.VALUE)) + 1d;
datafly *= Double.valueOf(line.get("DataFly", Analyzer.VALUE)) + 1d;
igreedy *= Double.valueOf(line.get("IGreedy", Analyzer.VALUE)) + 1d;
}
}
lightning = Double.valueOf(format((Math.pow(lightning, 1d/5d) - 1d) * 100d));
datafly = Double.valueOf(format((Math.pow(datafly, 1d/5d) - 1d) * 100d));
igreedy = Double.valueOf(format((Math.pow(igreedy, 1d/5d) - 1d) * 100d));
Object[] output = new String[]{criterion.toString(),
format(lightning, lightning, datafly, igreedy),
format(datafly, lightning, datafly, igreedy),
format(igreedy, lightning, datafly, igreedy)};
System.out.format(" - %-30s%-30s%-30s%-30s\n", output);
}
示例4: analyze
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Analyzes the results from one experiment
* @param file
* @param measure
* @param suppression
* @param criterion
* @throws ParseException
*/
private static void analyze(CSVFile file,
BenchmarkQualityMeasure measure,
double suppression,
BenchmarkPrivacyModel criterion) throws ParseException {
// Select
Selector<String[]> selector = file.getSelectorBuilder()
.field("Suppression limit").equals(String.valueOf(suppression)).and()
.field("Quality measure").equals(measure.toString()).and()
.field("Privacy model").equals(criterion.toString())
.build();
// Iterate
for (Iterator<CSVLine> iter = file.iterator(); iter.hasNext(); ) {
CSVLine line = iter.next();
if (selector.isSelected(line.getData())) {
double own = Double.valueOf(format(Double.valueOf(line.get("Lightning", Analyzer.VALUE)) * 100d));
double datafly = Double.valueOf(format(Double.valueOf(line.get("DataFly", Analyzer.VALUE)) * 100d));
double igreedy = Double.valueOf(format(Double.valueOf(line.get("IGreedy", Analyzer.VALUE)) * 100d));
Object[] output = new String[]{criterion.toString(),
line.get("", "Dataset"),
format(own, own, datafly, igreedy),
format(datafly, own, datafly, igreedy),
format(igreedy, own, datafly, igreedy)};
System.out.format(" - %-30s%-30s%-30s%-30s%-30s\n", output);
}
}
}
示例5: getSelected
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Selection process
* @param selector
* @param list
* @return
*/
private<T> List<Integer> getSelected(Selector<T> selector, List<T> list){
List<Integer> result = new ArrayList<Integer>();
for (int i=0; i<list.size(); i++) {
final T entry = list.get(i);
if (selector.isSelected(entry)) {
result.add(i);
}
}
return result;
}
示例6: analyze
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Analyzes the results from one experiment
* @param file
* @param measure
* @param suppression
* @param criterion
* @throws ParseException
*/
private static void analyze(CSVFile file,
BenchmarkQualityMeasure measure,
double suppression,
BenchmarkPrivacyModel criterion) throws ParseException {
// Select
Selector<String[]> selector = file.getSelectorBuilder()
.field("Suppression limit").equals(String.valueOf(suppression)).and()
.field("Quality measure").equals(measure.toString()).and()
.field("Privacy model").equals(criterion.toString())
.build();
// Iterate
for (Iterator<CSVLine> iter = file.iterator(); iter.hasNext(); ) {
CSVLine line = iter.next();
if (selector.isSelected(line.getData())) {
// Read values
double _flash = getValue(line, "Flash", 1d / 1000d);
double _lightning = getValue(line, "Lightning", 1d / 1000d);
double _utility = getValue(line, "Quality", 100d);
// Convert to strings
String discovery = "--";
String utility = "--";
String flash = null;
String lightning = null;
if (_utility != -100d) {
utility = format(100d - _utility);
discovery = format(getValue(line, "Discovery", 1d / 1000d));
}
flash = format(_flash);
lightning = format(_lightning);
// Discovery and total time of lightning are potentially measured in different benchmark runs.
// Due to fluctuations in the JVM execution times, discovery can thus be
// a bit larger than total time, when they are actually identical.
// We handle this special case here.
if (!discovery.equals("--") && Double.valueOf(discovery) > Double.valueOf(_lightning)) {
discovery = format(_lightning);
}
// Print
Object[] output = new String[]{line.get("", "Dataset"),
flash,
lightning,
discovery,
utility};
System.out.format("%-30s%-30s%-30s%-30s%-30s\n", output);
}
}
}
示例7: main
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Main entry
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// Create a set of 1000 elements
List<Integer[]> entries = new ArrayList<Integer[]>();
for (int i=0; i<1000; i++){
entries.add(getRandomEntry());
}
// Create header
ArrayAccessor<Integer> accessor = new ArrayAccessor<Integer>(new String[]{"field1", "field2", "field3"});
// Create a selector with the builder pattern
Selector<Integer[]> selector = new SelectorBuilder<Integer[]>(accessor).field("field1").leq(20)
.and()
.field("field2").leq(20)
.and()
.field("field3").leq(20)
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i=0; i<1000; i++) {
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: "+i);
}
}
// Create a selector by parsing a query string
selector = new SelectorBuilder<Integer[]>(accessor,
"'field1'<='20' and 'field2'<='20' and 'field3'<='20'")
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i=0; i<1000; i++) {
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: "+i);
}
}
}
示例8: main
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Main entry
*
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// Create a set of 1000 elements
Random random = new Random();
List<Element> entries = new ArrayList<Element>();
for (int i=0; i<1000; i++){
entries.add(Element.getRandomElement(random));
}
// Create a selector with the builder pattern
Selector<Element> selector = new SelectorBuilder<Element>(new ObjectAccessor<Element>(Element.class))
.begin()
.field("bool").equals(true)
.and()
.field("integer").geq(50)
.end()
.or()
.field("numeric").leq(30d)
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i = 0; i < 1000; i++) {
// Check
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: " + i);
}
}
// Create a selector by parsing a query string
selector = new SelectorBuilder<Element>(new ObjectAccessor<Element>(Element.class),
"('bool'='true' and 'integer'>='50') or 'numeric'<='30'")
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i = 0; i < 1000; i++) {
// Check
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: " + i);
}
}
}
示例9: main
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Main entry
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// Create a set of 1000 elements
List<Integer[]> entries = new ArrayList<Integer[]>();
for (int i=0; i<1000; i++){
entries.add(getRandomEntry());
}
// Create header
ArrayAccessor<Integer> accessor = new ArrayAccessor<Integer>(new String[]{"field1", "field2", "field3"});
// Create a selector with the builder pattern
Selector<Integer[]> selector = new SelectorBuilder<Integer[]>(accessor).field("field1").leq(20)
.and()
.field("field2").leq(20)
.and()
.field("field3").leq(20)
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i=0; i<1000; i++) {
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: "+i);
}
}
// Create a selector by parsing a query string
selector = new SelectorBuilder<Integer[]>(accessor,
"'field1'<='\\'\\\\a' and 'field2'<='20' and 'field3'<='20'")
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i=0; i<1000; i++) {
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: "+i);
}
}
}
示例10: main
import de.linearbits.objectselector.Selector; //导入方法依赖的package包/类
/**
* Main entry
* @param args
* @throws ParseException
*/
public static void main(String[] args) throws ParseException {
// Create a set of 1000 elements
Random random = new Random();
List<int[]> entries = new ArrayList<int[]>();
for (int i=0; i<1000; i++){
entries.add(Element.getRandomIntArray(random));
}
// Create header
IntArrayAccessor accessor = new IntArrayAccessor(new String[]{"field1", "field2", "field3"});
// Create a selector with the builder pattern
Selector<int[]> selector = new SelectorBuilder<int[]>(accessor).field("field1").leq(20)
.and()
.field("field2").leq(20)
.and()
.field("field3").leq(20)
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i=0; i<1000; i++) {
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: "+i);
}
}
// Create a selector by parsing a query string
selector = new SelectorBuilder<int[]>(accessor,
"'field1'<='20' and 'field2'<='20' and 'field3'<='20'")
.build();
// Print selector
System.out.println(selector.toString());
// Print, which elements are selected
for (int i=0; i<1000; i++) {
if (selector.isSelected(entries.get(i))) {
System.out.println("Is selected: "+i);
}
}
}