Increases the length of the SegmentChunk by the given delta.
@param delta The value to increase by.
5416
synchronized void increaseLength(long delta) {
        Preconditions.checkState(!this.sealed, "Cannot increase the length of a sealed SegmentChunk.");
        Preconditions.checkArgument(delta >= 0, "Cannot decrease the length of a SegmentChunk.");
        this.length += delta;
    }
1185452
def add_segment(self, segment):
        
        if self.segments:
            prev_seg = self.segments[-1]
            if prev_seg.mode == segment.mode and prev_seg.encoding == segment.encoding:
                # Merge segment with previous segment
                segment = _Segment(prev_seg.bits + segment.bits,
                                   prev_seg.char_count + segment.char_count,
                                   segment.mode, segment.encoding)
                self.bit_length -= len(prev_seg.bits)
                del self.segments[-1]
                del self.modes[-1]
        self.segments.append(segment)
        self.bit_length += len(segment.bits)
        self.modes.append(segment.mode)
558956
public void add(int deltaHi, int deltaLo) {
        while (true) {
            long encoded = get();
            long update = encode(getHi(encoded) + deltaHi, getLo(encoded) + deltaLo);
            if (compareAndSet(encoded, update))
                return;
        }
    }
124646
public int addAndGet(T obj, int delta) {
        int prev, next;
        do {
            prev = get(obj);
            next = prev + delta;
        } while (!compareAndSet(obj, prev, next));
        return next;
    }
17818
public void updateDataSegmentPosition(long iPosition, final int iDataSegmentId, final long iDataSegmentPosition)
      throws IOException {
    iPosition = iPosition * RECORD_SIZE;

    acquireExclusiveLock();
    try {

      final long[] pos = fileSegment.getRelativePosition(iPosition);

      final OFile f = fileSegment.files[(int) pos[0]];
      long p = pos[1];

      f.writeShort(p, (short) iDataSegmentId);
      f.writeLong(p += OBinaryProtocol.SIZE_SHORT, iDataSegmentPosition);

    } finally {
      releaseExclusiveLock();
    }
  }
1323591
public int addPrimitive(int index, int delta) {
        if (index < 0 || index >= maxLength) 
            throw new ArrayIndexOutOfBoundsException(
                    "invalid index: " + index);

        // Return immediately if this call would not change the array
        if (delta == 0)
            return get(index);
        
        int pos = Arrays.binarySearch(indices, index);
        
        // The add operation is putting a new value in the array, so we need to
        // make room in the indices array
        if (pos < 0) {
            int newPos = 0 - (pos + 1);
            int[] newIndices = Arrays.copyOf(indices, indices.length + 1);
            int[] newValues = Arrays.copyOf(values, values.length + 1);
            
            // shift the elements down by one to make room
            for (int i = newPos; i < values.length; ++i) {
                newValues[i+1] = values[i];
                newIndices[i+1] = indices[i];
            }
            
            // swap the arrays
            indices = newIndices;
            values = newValues;
            pos = newPos;
            
            // update the position of the pos in the values array
            indices[pos] = index;
            values[pos] = delta;
            return delta;
        }
        else {
            int newValue = values[pos] + delta;

            // The new value is zero, so remove its position and shift
            // everything over
            if (newValue == 0) {
                int newLength = indices.length - 1;
                int[] newIndices = new int[newLength];
                int[] newValues = new int[newLength];
                for (int i = 0, j = 0; i < indices.length; ++i) {
                    if (i != pos) {
                        newIndices[j] = indices[i];
                        newValues[j] = values[i];            
                        j++;
                    }
                }
                // swap the arrays
                indices = newIndices;
                values = newValues;
            }
            // Otherwise, the new value is still non-zero, so update it in the
            // array
            else
                values[pos] = newValue;
            return newValue;
        }
    }
1343200
public BigInteger getAndAdd(BigInteger delta) {
        while (true) {
        	BigInteger current = get();
        	BigInteger next = current.add(delta);
            if (compareAndSet(current, next))
                return current;
        }
    }
646831
public final double addAndGet(double delta) 
    {
        while(true) 
        {
            double orig = get();
            double newVal = orig + delta;
            if (compareAndSet(orig, newVal))
                return newVal;
        }
    }
462221
public int addAndGetHi(int delta) {
        while (true) {
            long encoded = get();
            int hi = getHi(encoded) + delta;
            long update = encodeHi(encoded, hi);
            if (compareAndSet(encoded, update))
                return hi;
        }
    }
1314884
private void expandIfNecessary(long dataLength) throws IOException {
    long elementLength = Element.HEADER_LENGTH + dataLength;
    long remainingBytes = remainingBytes();
    if (remainingBytes >= elementLength) return;

    // Expand.
    long previousLength = fileLength;
    long newLength;
    // Double the length until we can fit the new data.
    do {
      remainingBytes += previousLength;
      newLength = previousLength << 1;
      previousLength = newLength;
    } while (remainingBytes < elementLength);

    setLength(newLength);

    // Calculate the position of the tail end of the data in the ring buffer
    long endOfLastElement = wrapPosition(last.position + Element.HEADER_LENGTH + last.length);
    long count = 0;
    // If the buffer is split, we need to make it contiguous
    if (endOfLastElement <= first.position) {
      FileChannel channel = raf.getChannel();
      channel.position(fileLength); // destination position
      count = endOfLastElement - headerLength;
      if (channel.transferTo(headerLength, count, channel) != count) {
        throw new AssertionError("Copied insufficient number of bytes!");
      }
    }

    // Commit the expansion.
    if (last.position < first.position) {
      long newLastPosition = fileLength + last.position - headerLength;
      writeHeader(newLength, elementCount, first.position, newLastPosition);
      last = new Element(newLastPosition, last.length);
    } else {
      writeHeader(newLength, elementCount, first.position, last.position);
    }

    fileLength = newLength;

    if (zero) {
      ringErase(headerLength, count);
    }
  }
674317
public void shrink(int delta) {
        if (delta <= 0) {
            return;
        }

        int newLimit = buffer.limit() - delta;
        if (newLimit <= 0) {
            newLimit = 0;
        }
        this.buffer.limit(newLimit);
    }
1101323
public void plusDays(long delta)
    {
        if (delta != 0)
        {
            long result = getDay() + delta;
            if (result >= 1 && result <= 28)
            {
                setDay((int) result);
            }
            else
            {
                ZonedDateTime zonedDateTime = ZonedDateTime.from(this);
                ZonedDateTime plusDays = zonedDateTime.plusDays(delta);
                set(plusDays);
            }
        }
    }
786182
def setSectionLength(self, length):
        
        self._sectionLength = length
        for editor in self.editors():
            editor.setMaxLength(length)
461542
SegmentChunk withNewOffset(long newOffset) {
        SegmentChunk ns = new SegmentChunk(this.name, newOffset);
        ns.setLength(getLength());
        if (isSealed()) {
            ns.markSealed();
        }

        if (!exists()) {
            ns.markInexistent();
        }

        return ns;
    }
647889
public final void addToPendingCount(int delta) {
        int c; // note: can replace with intrinsic in jdk8
        do {} while (!U.compareAndSwapInt(this, PENDING, c = pending, c+delta));
    }
647786
public static void increment(String name, TagList list, long delta) {
    final MonitorConfig config = MonitorConfig.builder(name).withTags(list).build();
    increment(config, delta);
  }
322882
synchronized void addChunks(List<SegmentChunk> segmentChunks) {
        Preconditions.checkState(!this.sealed, "Cannot add SegmentChunks for a Sealed Handle.");
        long expectedOffset = 0;
        if (this.segmentChunks.size() > 0) {
            expectedOffset = this.segmentChunks.get(this.segmentChunks.size() - 1).getLastOffset();
        } else if (segmentChunks.size() > 0) {
            expectedOffset = segmentChunks.get(0).getStartOffset();
        }

        for (SegmentChunk s : segmentChunks) {
            Preconditions.checkArgument(s.getStartOffset() == expectedOffset,
                    "Invalid SegmentChunk StartOffset. Expected %s, given %s.", expectedOffset, s.getStartOffset());
            expectedOffset += s.getLength();
        }

        this.segmentChunks.addAll(segmentChunks);
        this.activeChunkHandle = null;
    }