Sets the iterator to refer to the last boundary position before the
specified position.
@param offset The position to begin searching for a break from.
@return The position of the last boundary before the starting position.
551210
@Override
    public int preceding(int offset) {
        CharacterIterator text = getText();

        // if we have no cached break positions, or "offset" is outside the
        // range covered by the cache, we can just call the inherited routine
        // (which will eventually call other routines in this class that may
        // refresh the cache)
        if (fCachedBreakPositions == null || offset <= fCachedBreakPositions[0] ||
                offset > fCachedBreakPositions[fCachedBreakPositions.length - 1]) {
            fCachedBreakPositions = null;
            return rulesPreceding(offset);
        }

        // on the other hand, if "offset" is within the range covered by the cache,
        // then all we have to do is search the cache for the last break position
        // before "offset"
        else {
            fPositionInCache = 0;
            while (fPositionInCache < fCachedBreakPositions.length
                   && offset > fCachedBreakPositions[fPositionInCache])
                ++fPositionInCache;
            --fPositionInCache;
            text.setIndex(fCachedBreakPositions[fPositionInCache]);
            return text.getIndex();
        }
    }
409349
public long getOffset() throws IOException {
        if (offset == null) {
            read();
            SectionTable table = data.getSectionTable();
            SectionLoader loader = new SectionLoader(data);
            offset = 0L;
            List<SectionHeader> headers = table.getSectionHeaders();
            // TODO low alingment check instead?
//            if (headers.size() == 0) { // offset for sectionless PE's
//                offset = file.length();
//            }
            for (SectionHeader section : headers) {
                long alignedPointerToRaw = section.getAlignedPointerToRaw();
                long readSize = loader.getReadSize(section);
                // ignore invalid sections
                // corkami: "if a section starts at [unaligned] offset 0, it's invalid."
                if (readSize == 0 || section.get(SectionHeaderKey.POINTER_TO_RAW_DATA) == 0) {
                    continue;
                }
                long endPoint = readSize + alignedPointerToRaw;
                if (offset < endPoint) { // determine largest endPoint
                    offset = endPoint;
                }
            }
        }
        if (offset > file.length() || offset == 0) {
            offset = file.length();
        }
        return offset;
    }
541349
CompletableFuture<EventPosition> getInitialOffset() {
        return this.hostContext.getCheckpointManager().getCheckpoint(this.partitionId)
                .thenApply((startingCheckpoint) -> {
                    return checkpointToOffset(startingCheckpoint);
                }
441335
protected boolean checkNextIndexOffset() {
		if (this.currentSortIndexOffset > this.lastIndexEntryOffset) {
			MemorySegment returnSegment = nextMemorySegment();
			if (returnSegment != null) {
				this.currentSortIndexSegment = returnSegment;
				this.sortIndex.add(this.currentSortIndexSegment);
				this.currentSortIndexOffset = 0;
			} else {
				return false;
			}
		}
		return true;
	}
124145
public void seek(int offset) throws IOException {
    if (!(offset >= bufferOffset && offset < bufferOffset + maxBufferSize)) {
      writeBuffer();
      newBuffer(offset);
      aFile.seek(offset);
    }
    position = offset;
  }
596295
private int nextBoundaryAfter(int startIndex) {
        BreakIterator breakiterator = search_.breakIter();

        if (breakiterator == null) {
            breakiterator = search_.internalBreakIter_;
        }

        if (breakiterator != null) {
            return breakiterator.following(startIndex);
        }

        return startIndex;
    }
1040207
long getEndOffsetForSegment(Segment segment) {
        return Optional.ofNullable(sync.getState().getEndSegments().get(segment)).orElse(Long.MAX_VALUE);
    }
485794
public T setStartOffset(long offset, TimeUnit units) {
    checkNotNull(units);

    this.startOffset = units.toMillis(offset);

    return getThis();
  }
675988
final public void setRealOffset(Integer start, Integer end) {
    if ((start == null) || (end == null)) {
      // do nothing
    } else if (start > end) {
      throw new IllegalArgumentException(
          "Start real offset after end real offset");
    } else {
      tokenRealOffset = new MtasOffset(start, end);
    }
  }
909697
@Override
    public int lastIndexOf(Object o) {
        if (displacement != null) {
            return super.lastIndexOf(o) + displacement;
        }
        return super.lastIndexOf(o);
    }
63360
protected int levelOffset(Context context) {
        //TODO: Unused method, make sure this is never used and then remove it.
        int levelOffset;
        switch (context.position) {
            case DOCUMENT_BEFORE:
            case DOCUMENT_AFTER:
                levelOffset = 0;
                break;
            case DOCUMENT_BEGIN:
            case DOCUMENT_END:
                levelOffset = 1;
                break;
            default:
                throw new RuntimeException(String.format("Unknown position '%s'", context.position));
        }

        return levelOffset;
    }
104480
@Override
    public Iterator<E> iterator() {
        return new Iterator<E>() {

            private int index = start;
            private int lastReturnedIndex = -1;
            private boolean isFirst = full;

            @Override
            public boolean hasNext() {
                return isFirst || index != end;
            }

            @Override
            public E next() {
                if (!hasNext()) {
                    throw new NoSuchElementException();
                }
                isFirst = false;
                lastReturnedIndex = index;
                index = increment(index);
                return elements[lastReturnedIndex];
            }

            @Override
            public void remove() {
                if (lastReturnedIndex == -1) {
                    throw new IllegalStateException();
                }

                // First element can be removed quickly
                if (lastReturnedIndex == start) {
                    CircularFifoQueue.this.remove();
                    lastReturnedIndex = -1;
                    return;
                }

                int pos = lastReturnedIndex + 1;
                if (start < lastReturnedIndex && pos < end) {
                    // shift in one part
                    System.arraycopy(elements, pos, elements, lastReturnedIndex, end - pos);
                } else {
                    // Other elements require us to shift the subsequent elements
                    while (pos != end) {
                        if (pos >= maxElements) {
                            elements[pos - 1] = elements[0];
                            pos = 0;
                        } else {
                            elements[decrement(pos)] = elements[pos];
                            pos = increment(pos);
                        }
                    }
                }

                lastReturnedIndex = -1;
                end = decrement(end);
                elements[end] = null;
                full = false;
                index = decrement(index);
            }

        };
    }
747202
public Collection<BasicBlock> getBlocksContainingInstructionWithOffset(int offset) {
        LinkedList<BasicBlock> result = new LinkedList<>();
        for (Iterator<BasicBlock> i = blockIterator(); i.hasNext();) {
            BasicBlock block = i.next();
            if (block.containsInstructionWithOffset(offset)) {
                result.add(block);
            }
        }
        return result;
    }
515126
public Integer getEnd() {
    if (mtasPositionType.equals(POSITION_RANGE)
        || mtasPositionType.equals(POSITION_SET)) {
      return mtasPositionEnd;
    } else if (mtasPositionType.equals(POSITION_SINGLE)) {
      return mtasPositionStart;
    } else {
      return null;
    }
  }
249635
void setOffset(long value) {
        if (this.pointer != null && this.offset.get() != this.pointer.getOffset()) {
            // We have already assigned an offset to this.
            throw new IllegalStateException("Cannot assign offset more than once.");
        }

        this.offset.set(value);
    }
374458
@Default
	public int getOffset() {
		String value = getValue();
		String superstring = getSuperstring();
		return value != null && superstring != null ? superstring.indexOf(value) : -1;
	}
1104913
public Object elementAt(int iTargetPosition)
    {
        Record record = null;
        Object bookmark = null;
        if (m_iEndOfFileIndex != UNKNOWN_POSITION) if (iTargetPosition >= m_iEndOfFileIndex)
            return null;    // Past/At EOF
        if (!m_gridBuffer.inBufferList(iTargetPosition))
        {
            bookmark = m_gridList.elementAt(iTargetPosition);
            if (bookmark != null)
                return bookmark;    // In grid list, return it!
            // Find the next lower item in the list
            int iLowestNonNullIndex = this.lowestNonNullIndex(iTargetPosition);
            if (iLowestNonNullIndex != -1)
            {
                bookmark = m_gridList.elementAt(iLowestNonNullIndex);
                if (bookmark == null)
                    bookmark = m_gridBuffer.elementAt(iLowestNonNullIndex);
            }
            
            boolean bFindTargetUsingCurrentQuery = false;
            if (bookmark == null)
                bFindTargetUsingCurrentQuery = true;
            else
            {
                if (iTargetPosition == m_iPhysicalFilePosition + 1)
                    if (m_bIsSequentialQueryValid)
                        bFindTargetUsingCurrentQuery = true;
            }

            if (!bFindTargetUsingCurrentQuery)
            { // This record is not in the grid list, because the granularity is too great
                // Read the record before it, and move forward.
                // Move to > bookmark, and move next until you hit this target.
                this.getNextTable().setDataRecord((DataRecord)bookmark);
                record = this.getRecord();
                if (m_behCompare != null)
                    record.removeListener(m_behCompare, true);
                m_behCompare = new SubCurrentFilter(true, false);
                m_behCompare.setMasterSlaveFlag(RecordOwner.MASTER | RecordOwner.SLAVE);    // Should run in either space
                record.addListener(m_behCompare);
                this.getNextTable().close();
                this.getRecord().setOpenMode(this.getRecord().getOpenMode() | DBConstants.OPEN_SUPPRESS_MESSAGES);   // Don't send an "AFTER_REQUERY_TYPE" message
                try   {
                    m_iPhysicalFilePosition = iLowestNonNullIndex - 1;
                    m_bIsSequentialQueryValid = true;
                    record = (Record)this.move(+1);
                    m_iPhysicalFilePosition = iLowestNonNullIndex;
                } catch (DBException e)   {
                    record = null;
                } finally {
                    this.getRecord().setOpenMode(this.getRecord().getOpenMode() & ~DBConstants.OPEN_SUPPRESS_MESSAGES);
                }
                if (record == null) if (m_behCompare != null)
                {
                    this.getRecord().removeListener(m_behCompare, true);
                    m_behCompare = null;
                }
            }

            try   {
                int iCurrentPosition = m_iPhysicalFilePosition;
                if (iCurrentPosition == -1)
                {
                    for (iCurrentPosition = 0; ; iCurrentPosition++)
                    {       // Find the first non-deleted record
                        if ((!m_gridBuffer.inBufferList(iCurrentPosition))
                            || (m_gridBuffer.elementAt(iCurrentPosition) != null))
                                break;
                    }
                    record = (Record)this.move(DBConstants.FIRST_RECORD);
                    if (record != null)
                    {
                        if (iCurrentPosition != 0)
                        {
                            bookmark = m_gridList.elementAt(0);
                            if (bookmark == null)
                                bookmark = m_gridBuffer.elementAt(0);
                            m_gridBuffer.addElement(0, null, m_gridList);   // Set this as deleted again
                            m_gridBuffer.addElement(iCurrentPosition, bookmark, m_gridList);   // Set this in the right logical position
                            m_iPhysicalFilePosition = iCurrentPosition;
                        }
                    }
                    else
                    {
                        iTargetPosition = 0;    // Make sure current position = 0!
                        m_iEndOfFileIndex = 0;  // EOF + 1
                    }
                }
                int iMoveRelative = iTargetPosition - iCurrentPosition;
                if (iMoveRelative < 0)
                    record = (Record)this.move(iMoveRelative);
                else
                {
                    while (iMoveRelative > 0)
                    {
                        if ((m_gridBuffer.inBufferList(m_iPhysicalFilePosition + 1))
                            && (m_gridBuffer.elementAt(m_iPhysicalFilePosition + 1) == null))
                        {
                            m_iPhysicalFilePosition++;  // This record shows deleted, don't fill with a record.
                        }
                        else
                        {
                            record = (Record)this.move(+1);
                            if (record == null)
                                break;
                        }
                        iMoveRelative--;
                    }
                }
                m_bIsSequentialQueryValid = true; // The query is in force, you may use move(+1) next time (instead of starting a new query)
            } catch (DBException ex)    {
                ex.printStackTrace();
                record = null;
            }
            m_iPhysicalFilePosition = iTargetPosition;
            if (m_behCompare != null)
            {
                this.getRecord().removeListener(m_behCompare, true);
                m_behCompare = null;
            }
            if (record == null)
                return null;
        }
        if (m_gridBuffer.inBufferList(iTargetPosition))
            bookmark = m_gridBuffer.elementAt(iTargetPosition);
        else
            bookmark = m_gridList.elementAt(iTargetPosition);
        return bookmark;
    }