public void add( long[] vals ) { synchronized( mutex ) { list.add( vals ); } } public void add( long[] vals, int offset, int length ) {
public static boolean isClockwiseWay(TLongList c) { if (c.size() == 0) { return true; for (int i = 0; i < c.size(); i++) { middleY = middleY + (long)(c.get(i) & mask); middleY = middleY /(long) c.size(); int firstX = Integer.MIN_VALUE; int prevX = (int) (c.get(0) >> 32); int prevY = (int) (c.get(0) & mask); for (int i = 1; i < c.size(); i++) { int x = (int) (c.get(i) >> 32); int y = (int) (c.get(i) & mask); int rX = ray_intersect_x(prevX, prevY, x, y, (int) middleY); if (rX != Integer.MIN_VALUE) {
public long[] toArray( int offset, int len ) { synchronized( mutex ) { return list.toArray( offset, len ); } } public long[] toArray( long[] dest, int offset, int len ) {
@Override public Long get( int index ) { long value = list.get( index ); if ( value == list.getNoEntryValue() ) return null; else return Long.valueOf( value ); }
@Override public Long set( int index, Long value ) { long previous_value = list.set( index, value ); if ( previous_value == list.getNoEntryValue() ) return null; else return Long.valueOf( previous_value ); }
public void add(@NonNull DateTime ts) { final long tsMillis = ts.getMillis(); if (timestamps.isEmpty() || tsMillis > frontLong()) { timestamps.add(tsMillis); } else { final int bsPos = timestamps.binarySearch(tsMillis); if (bsPos < 0) { // Insert only if not present. final int insPos = -(bsPos + 1); timestamps.insert(insPos, tsMillis); } } }
@Override public PersistedData serializeCollection(Collection<EntityRef> value, SerializationContext context) { TLongList items = new TLongArrayList(); for (EntityRef ref : value) { if (!ref.exists()) { items.add(0L); } else { if (ref.isPersistent()) { items.add((ref).getId()); } else { items.add(0L); } } } return context.create(items.iterator()); }
@Override public void endDocument() { // After the entire diff has been applied, re-index all the ways that were added or modified. if (!waysModified.isEmpty()) { LOG.debug("Indexing modified ways..."); for (int w = 0; w < waysModified.size(); w++) { // TODO unless we are doing snapshots and transactions, we should unindex after indexing the new one? osm.unIndexWay(id); osm.indexWay(waysModified.get(w), null); } } }
@Override public int size() { return list.size(); }
public long get( int index ) { synchronized( mutex ) { return list.get( index ); } } public long set( int index, long element) {
public void sort() { synchronized( mutex ) { list.sort(); } } public void sort( int fromIndex, int toIndex ) {
private void applyPermissions(AbstractChannelImpl<?> channel, JSONObject content, JSONArray permOverwrites, List<IPermissionHolder> contained, List<IPermissionHolder> changed) { //Determines if a new PermissionOverride was created or updated. //If a PermissionOverride was created or updated it stores it in the proper Map to be reported by the Event. for (int i = 0; i < permOverwrites.length(); i++) { handlePermissionOverride(permOverwrites.getJSONObject(i), channel, content, changed, contained); } //Check if any overrides were deleted because of this event. //Get the current overrides. (we copy them to a new list because the Set returned is backed by the Map, meaning our removes would remove from the Map. Not good. //Loop through all of the json defined overrides. If we find a match, remove the User or Role from our lists. //Any entries remaining in these lists after this for loop is over will be removed from the Channel's overrides. final TLongList toRemove = new TLongLinkedList(); final TLongObjectMap<PermissionOverride> overridesMap = channel.getOverrideMap(); TDecorators.wrap(overridesMap.keySet()).stream() .map(id -> mapPermissionHolder(id, channel.getGuild())) .filter(Objects::nonNull) .filter(permHolder -> !contained.contains(permHolder)) .forEach(permHolder -> { changed.add(permHolder); toRemove.add(getIdLong(permHolder)); }); toRemove.forEach((id) -> { overridesMap.remove(id); return true; }); }
public TLongList subList( int fromIndex, int toIndex ) { synchronized( mutex ) { return new TSynchronizedLongList( list.subList( fromIndex, toIndex ), mutex ); } }
public int binarySearch( long value ) { synchronized( mutex ) { return list.binarySearch( value ); } } public int binarySearch( long value, int fromIndex, int toIndex ) {
public void insert( int offset, long[] values ) { synchronized( mutex ) { list.insert( offset, values ); } } public void insert( int offset, long[] values, int valOffset, int len ) {
public long set( int index, long element) { synchronized( mutex ) { return list.set( index, element ); } } public void set( int offset, long[] values ) {
@Override public Long get( int index ) { long value = list.get( index ); if ( value == list.getNoEntryValue() ) return null; else return Long.valueOf( value ); }