Search in sources :

Example 1 with LongsBuilder

use of suite.primitive.Longs.LongsBuilder in project suite by stupidsing.

the class LngOutlet method toList.

public LongsBuilder toList() {
    LongsBuilder list = new LongsBuilder();
    long c;
    while ((c = next()) != LngFunUtil.EMPTYVALUE) list.append(c);
    return list;
}
Also used : LongsBuilder(suite.primitive.Longs.LongsBuilder)

Example 2 with LongsBuilder

use of suite.primitive.Longs.LongsBuilder in project suite by stupidsing.

the class HongKongGovernment method queryWeather.

public Map<String, DataSource> queryWeather() {
    long t0 = Time.of(2000, 1, 1).epochSec();
    long tx = Time.today().epochSec();
    LongsBuilder ts = new LongsBuilder();
    FloatsBuilder fs0 = new FloatsBuilder();
    FloatsBuilder fs1 = new FloatsBuilder();
    for (long t = t0; t < tx; t += 86400l) {
        Time time = Time.ofEpochSec(t);
        String html = // 
        Singleton.me.storeCache.http(// 
        "http://www.hko.gov.hk/cgi-bin/hko/yes.pl" + "?year=" + // 
        time.year() + "&month=" + // 
        time.month() + "&day=" + // 
        time.dayOfMonth() + // 
        "&language=english&B1=Confirm#").collect(As::string);
        String data = ParseUtil.fit(html, "<pre>", "</pre>")[1];
        ts.append(t);
        fs0.append(getFloatValue(data, "Maximum Air Temperature", "C"));
        fs1.append(getFloatValue(data, "Rainfall", "mm"));
    }
    long[] ts_ = ts.toLongs().toArray();
    return // 
    Map.ofEntries(// 
    entry("hko.TEMP", DataSource.of(ts_, fs0.toFloats().toArray())), entry("hko.RAIN", DataSource.of(ts_, fs1.toFloats().toArray())));
}
Also used : As(suite.streamlet.As) LongsBuilder(suite.primitive.Longs.LongsBuilder) Time(suite.trade.Time) FloatsBuilder(suite.primitive.Floats.FloatsBuilder)

Example 3 with LongsBuilder

use of suite.primitive.Longs.LongsBuilder in project suite by stupidsing.

the class LngOutlet method toListMap.

public <K> LngObjMap<LongsBuilder> toListMap(Lng_Lng valueFun) {
    LngObjMap<LongsBuilder> map = new LngObjMap<>();
    long c;
    while ((c = next()) != LngFunUtil.EMPTYVALUE) map.computeIfAbsent(c, k_ -> new LongsBuilder()).append(valueFun.apply(c));
    return map;
}
Also used : LngObjMap(suite.primitive.adt.map.LngObjMap) LongsBuilder(suite.primitive.Longs.LongsBuilder)

Aggregations

LongsBuilder (suite.primitive.Longs.LongsBuilder)3 FloatsBuilder (suite.primitive.Floats.FloatsBuilder)1 LngObjMap (suite.primitive.adt.map.LngObjMap)1 As (suite.streamlet.As)1 Time (suite.trade.Time)1