it.unimi.dsi.fastutil.shorts.ShortArrayList Java Examples

The following examples show how to use it.unimi.dsi.fastutil.shorts.ShortArrayList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnhancedTTSP.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
public EnhancedTTSP(final List<Location> locations, final short startLocation, final List<Boolean> blockedHours, final double hourOfDeparture, final double maxConsecutiveDrivingTime,
		final double durationOfShortBreak, final double durationOfLongBreak) {
	super();
	this.startLocation = startLocation;
	this.numberOfConsideredHours = blockedHours.size();
	this.locations = locations;
	for (Location l : locations) {
		this.xCoords.put(l.getId(), l.getX());
		this.yCoords.put(l.getId(), l.getY());
	}
	this.blockedHours = blockedHours;
	this.hourOfDeparture = hourOfDeparture;
	this.durationOfShortBreak = durationOfShortBreak;
	this.durationOfLongBreak = durationOfLongBreak;
	this.maxConsecutiveDrivingTime = maxConsecutiveDrivingTime;
	this.maxDrivingTimeBetweenLongBreaks = 24 - durationOfLongBreak;
	this.possibleDestinations = new ShortArrayList(locations.stream().map(Location::getId).sorted().collect(Collectors.toList()));
	this.solutionEvaluator = new EnhancedTTSPSolutionEvaluator(this);
}
 
Example #2
Source File: AvroRecordConverter.java    From parquet-mr with Apache License 2.0 6 votes vote down vote up
@Override
public void end() {
  if (elementClass == boolean.class) {
    parent.add(((BooleanArrayList) container).toBooleanArray());
  } else if (elementClass == byte.class) {
    parent.add(((ByteArrayList) container).toByteArray());
  } else if (elementClass == char.class) {
    parent.add(((CharArrayList) container).toCharArray());
  } else if (elementClass == short.class) {
    parent.add(((ShortArrayList) container).toShortArray());
  } else if (elementClass == int.class) {
    parent.add(((IntArrayList) container).toIntArray());
  } else if (elementClass == long.class) {
    parent.add(((LongArrayList) container).toLongArray());
  } else if (elementClass == float.class) {
    parent.add(((FloatArrayList) container).toFloatArray());
  } else if (elementClass == double.class) {
    parent.add(((DoubleArrayList) container).toDoubleArray());
  } else {
    parent.add(((ArrayList) container).toArray());
  }
}
 
Example #3
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 6 votes vote down vote up
@Override
public ShortColumn lag(int n) {
  final int srcPos = n >= 0 ? 0 : 0 - n;
  final short[] dest = new short[size()];
  final int destPos = n <= 0 ? 0 : n;
  final int length = n >= 0 ? size() - n : size() + n;

  for (int i = 0; i < size(); i++) {
    dest[i] = ShortColumnType.missingValueIndicator();
  }

  short[] array = data.toShortArray();

  System.arraycopy(array, srcPos, dest, destPos, length);
  return new ShortColumn(name() + " lag(" + n + ")", new ShortArrayList(dest));
}
 
Example #4
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 6 votes vote down vote up
@Override
public ShortColumn lag(int n) {
  final int srcPos = n >= 0 ? 0 : 0 - n;
  final short[] dest = new short[size()];
  final int destPos = n <= 0 ? 0 : n;
  final int length = n >= 0 ? size() - n : size() + n;

  for (int i = 0; i < size(); i++) {
    dest[i] = ShortColumnType.missingValueIndicator();
  }

  short[] array = data.toShortArray();

  System.arraycopy(array, srcPos, dest, destPos, length);
  return new ShortColumn(name() + " lag(" + n + ")", new ShortArrayList(dest));
}
 
Example #5
Source File: PLInferenceProblemEncoder.java    From AILibs with GNU Affero General Public License v3.0 6 votes vote down vote up
public PLInferenceProblem encode(final Collection<? extends List<?>> rankings) {
	if (this.ext2int != null) {
		throw new IllegalStateException();
	}
	this.ext2int = new HashMap<>();
	List<ShortList> encodedRankings = new ArrayList<>(rankings.size());
	this.items = new ArrayList<>();
	for (List<?> ranking : rankings) {
		ShortList encodedRanking = new ShortArrayList();
		for (Object o : ranking) {
			short index = this.ext2int.computeIfAbsent(o, obj -> (short)this.ext2int.size());
			if (!this.items.contains(o)) {
				this.items.add(o);
			}
			encodedRanking.add(index);
		}
		encodedRankings.add(encodedRanking);
	}
	return new PLInferenceProblem(encodedRankings);
}
 
Example #6
Source File: EnhancedTTSPState.java    From AILibs with GNU Affero General Public License v3.0 5 votes vote down vote up
private ShortList getCurTourRec() {
	if (this.parent == null) {
		return new ShortArrayList(); // the starting location will NOT be part of the tour!
	}
	ShortList l = this.parent.getCurTourRec();
	l.add(this.curLocation);
	return l;
}
 
Example #7
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
public static ShortColumn create(final String name, final int initialSize) {
  ShortColumn column = new ShortColumn(name, new ShortArrayList(initialSize));
  for (int i = 0; i < initialSize; i++) {
    column.appendMissing();
  }
  return column;
}
 
Example #8
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 5 votes vote down vote up
public static ShortColumn create(final String name, final int initialSize) {
  ShortColumn column = new ShortColumn(name, new ShortArrayList(initialSize));
  for (int i = 0; i < initialSize; i++) {
    column.appendMissing();
  }
  return column;
}
 
Example #9
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
protected ShortColumn(final String name, ShortArrayList data) {
  super(ShortColumnType.instance(), name);
  setPrintFormatter(NumberColumnFormatter.ints());
  this.data = data;
}
 
Example #10
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortDescending() {
  short[] elements = values.toShortArray();
  ShortArrays.parallelQuickSort(elements, reverseDictionarySortComparator);
  this.values = new ShortArrayList(elements);
}
 
Example #11
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortAscending() {
  short[] elements = values.toShortArray();
  ShortArrays.parallelQuickSort(elements, dictionarySortComparator);
  this.values = new ShortArrayList(elements);
}
 
Example #12
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
ShortArrayList values() {
  return values;
}
 
Example #13
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static ShortColumn create(final String name, final Short[] arr) {
  return new ShortColumn(name, new ShortArrayList(Shorts.toArray(Arrays.asList(arr))));
}
 
Example #14
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static ShortColumn create(final String name, final short... arr) {
  return new ShortColumn(name, new ShortArrayList(arr));
}
 
Example #15
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static ShortColumn create(final String name) {
  return new ShortColumn(name, new ShortArrayList());
}
 
Example #16
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static ShortColumn create(final String name) {
  return new ShortColumn(name, new ShortArrayList());
}
 
Example #17
Source File: AttributeStores.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
ShortAttributeStore(AttributeInfo attrInfo) {
    super(attrInfo);
    this.list = new ShortArrayList();
}
 
Example #18
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortDescending() {
  short[] elements = values.toShortArray();
  ShortArrays.parallelQuickSort(elements, reverseDictionarySortComparator);
  this.values = new ShortArrayList(elements);
}
 
Example #19
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
@Override
public void sortAscending() {
  short[] elements = values.toShortArray();
  ShortArrays.parallelQuickSort(elements, dictionarySortComparator);
  this.values = new ShortArrayList(elements);
}
 
Example #20
Source File: ShortDictionaryMap.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
ShortArrayList values() {
  return values;
}
 
Example #21
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
protected ShortColumn(final String name, ShortArrayList data) {
  super(ShortColumnType.instance(), name);
  setPrintFormatter(NumberColumnFormatter.ints());
  this.data = data;
}
 
Example #22
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static ShortColumn create(final String name, final Short[] arr) {
  return new ShortColumn(name, new ShortArrayList(Shorts.toArray(Arrays.asList(arr))));
}
 
Example #23
Source File: ShortColumn.java    From tablesaw with Apache License 2.0 4 votes vote down vote up
public static ShortColumn create(final String name, final short... arr) {
  return new ShortColumn(name, new ShortArrayList(arr));
}