10using System.Collections.Generic;
14 public static class Values {
19 public static Query<T> Single<T>(T value) {
20 var array = ArrayPool<T>.Spawn(1);
22 return new Query<T>(array, 1);
29 public static Query<T> Repeat<T>(T value,
int times) {
30 var array = ArrayPool<T>.Spawn(times);
31 for (
int i = 0; i < times; i++) {
34 return new Query<T>(array, times);
40 public static Query<T> Empty<T>() {
41 var array = ArrayPool<T>.Spawn(0);
42 return new Query<T>(array, 0);
57 public static Query<int> Range(
int from,
int to,
int step = 1,
bool endIsExclusive =
true) {
59 throw new ArgumentException(
"Step must be positive and non-zero.");
62 List<int> values = Pool<List<int>>.Spawn();
65 int sign = Utils.Sign(to - from);
68 while (Utils.Sign(to - value) == sign) {
74 if (!endIsExclusive && value == to) {
78 return new Query<int>(values);
81 Pool<List<int>>.Recycle(values);