use of gnu.trove.set.hash.TLongHashSet in project OpenTripPlanner by opentripplanner.
the class HashGridSpatialIndex method insert.
public final void insert(LineString geom, final Object item) {
Coordinate[] coord = geom.getCoordinates();
final TLongSet keys = new TLongHashSet(coord.length * 8);
for (int i = 0; i < coord.length - 1; i++) {
// TODO Cut the segment if longer than bin size
// to reduce the number of wrong bins
Envelope env = new Envelope(coord[i], coord[i + 1]);
visit(env, true, new BinVisitor<T>() {
@Override
public boolean visit(List<T> bin, long mapKey) {
keys.add(mapKey);
return false;
}
});
}
keys.forEach(new TLongProcedure() {
@SuppressWarnings("unchecked")
@Override
public boolean execute(long key) {
// Note: bins have been initialized in the previous visit
bins.get(key).add((T) item);
nEntries++;
return true;
}
});
nObjects++;
}
use of gnu.trove.set.hash.TLongHashSet in project PorkBot by DaMatrix.
the class AudioUtils method init.
public static void init() {
youTube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) {
}
}).setApplicationName("youtube-cmdline-search-sample").build();
devKey = KeyGetter.getDevKey();
musicManagers = new TSynchronizedLongObjectMap<>(new TLongObjectHashMap<>());
playerManager = new DefaultAudioPlayerManager();
AudioSourceManagers.registerRemoteSources(playerManager);
AudioSourceManagers.registerLocalSource(playerManager);
PorkBot.timer.schedule(new TimerTask() {
@Override
public void run() {
TLongSet toRemove = new TLongHashSet();
long now = System.currentTimeMillis();
musicManagers.forEachEntry((key, value) -> {
A: {
if (value.channel == null) {
// System.out.println("Removing guild because: missing channel");
toRemove.add(key);
break A;
}
if (value.created + 10000 < now && (value.channel.getMembers().size() < 2 || (value.manager.scheduler.queue.size() == 0 && value.manager.player.getPlayingTrack() == null))) {
// nobody's in the channel
// System.out.println("Removing guild because: empty");
value.manager.player.destroy();
value.channel.getGuild().getAudioManager().closeAudioConnection();
toRemove.add(key);
break A;
}
}
return true;
});
toRemove.forEach(l -> {
musicManagers.remove(l);
return true;
});
// not sure why or how this is happening, but it does apparently
List<AudioManager> list = ShardUtils.getConnectedVoice();
for (AudioManager manager : list) {
if (manager.getConnectedChannel().getMembers().size() < 2) {
manager.closeAudioConnection();
}
}
}
}, 10000, 5000);
}
Aggregations