Returns the segment for the given index.

@param index The index for which to return the segment.
@throws IllegalStateException if the segment manager is not open
347954
public synchronized Segment segment(long index) {
    assertOpen();
    // Check if the current segment contains the given index first in order to prevent an unnecessary map lookup.
    if (currentSegment != null && currentSegment.validIndex(index))
      return currentSegment;

    // If the index is in another segment, get the entry with the next lowest first index.
    Map.Entry<Long, Segment> segment = segments.floorEntry(index);
    return segment != null ? segment.getValue() : null;
  }
1060474
public Object opt(int index) {

        return ((index < 0) || (index >= length())) ? null : m_myArrayList.get(index);
    }
1336810
@Override
    public T get(int index) {
        if (displacement != null) {
            return super.get(index - displacement);
        }
        return super.get(index);
    }
79677
public boolean get(int index) throws ArrayIndexOutOfBoundsException {
        if (index < 0 || index >= length) {
            throw new ArrayIndexOutOfBoundsException(Integer.toString(index));
        }

        return (repn[subscript(index)] & position(index)) != 0;
    }
508272
public function segment($index) {
		if (isset($this->segments[$index])) {
			return $this->segments[$index];
		}

		return null;
	}
1274888
protected void decrOriginalSegmentLoad(int index) {
        try {
            long address = getAddress(index);
            int segPos = _addressFormat.getOffset(address);
            int segInd = _addressFormat.getSegment(address);
            int length = _addressFormat.getDataSize(address);
            
            if (segPos >= Segment.dataStartPosition) {
                // get data segment
                Segment seg = _segmentManager.getSegment(segInd);
                
                // read data length
                if(seg != null) seg.decrLoadSize(4 + ((length == 0) ? seg.readInt(segPos) : length));
            }
        }
        catch(IOException e1) {}
        catch(IndexOutOfBoundsException e2) {}
    }
455639
public <T extends MPBase> T getByIndex(int index) {
        T resource = (T) _resourceArray.get(index);
        return resource;
    }
690507
public int getField(int index)
	{
		assert (index >= 0 && index < version.length);

		if (index >= 0 && index < this.version.length)
		{
			return version[index];
		}
		else
		{
			throw new IllegalArgumentException("The field index requested does not exist in this Version object");
		}
	}
1102846
@Override
	public void add(int index, ST segment) {
		if (index < 0 || index > this.segmentList.size()) {
			throw new IndexOutOfBoundsException();
		}
		// The path is empty, so that the segment is the first one.
		if (this.segmentList.isEmpty()) {
			if (this.segmentList.add(segment)) {
				this.startingPoint = segment.getBeginPoint();
				this.endingPoint = segment.getEndPoint();
				this.length += segment.getLength();
				return;
			}
			throw new IllegalArgumentException();
		}

		// Detect the candidates to the connection
		final PT candidate;

		this.isReversable = false;

		if (index < this.segmentList.size()) {
			candidate = getStartingPointFor(index);
		} else {
			candidate = this.endingPoint;
		}

		// Check the connection validity
		if (candidate != null) {
			final PT first = segment.getBeginPoint();
			final PT last = segment.getEndPoint();
			if (index == 0 && (candidate.equals(first) || candidate.equals(last))) {
				this.segmentList.add(0, segment);
				this.startingPoint = segment.getOtherSidePoint(this.startingPoint);
				this.length += segment.getLength();
				return;
			} else if (index == this.segmentList.size() && (candidate.equals(first) || candidate.equals(last))) {
				this.segmentList.add(segment);
				this.endingPoint = segment.getOtherSidePoint(this.endingPoint);
				this.length += segment.getLength();
				return;
			} else if (candidate.equals(first) || candidate.equals(last)) {
				this.segmentList.add(index, segment);
				this.length += segment.getLength();
				return;
			}
		}

		throw new IllegalArgumentException();
	}
492770
public ByteBuffer get(final int index) {
		if (!validState) {
			throw new InvalidStateException();
		}
		if (log.isDebugEnabled()) {
			log.debug("get(" + index + ")");
		}
		try {
			if (useMmap) {
				final MappedByteBuffer mbb = getMmapForIndex(index);
				if (mbb != null) {
					return mbb;
				}
				// Fallback to RAF
			}
			final ByteBuffer buf = bufstack.pop();
			fileChannel.position(index * blockSize).read(buf);
			buf.rewind();
			return buf;
		} catch (Exception e) {
			log.error("Exception in get(" + index + ")", e);
		}
		return null;
	}
571102
@Pure
	public int indexOf(RoadSegment segment) {
		int count = 0;
		int index;
		for (final RoadPath p : this.paths) {
			index = p.indexOf(segment);
			if (index >= 0) {
				return count + index;
			}
			count += p.size();
		}
		return -1;
	}
969783
public synchronized XEvent get(int index) throws IndexOutOfBoundsException,
			IOException {
		if (index < 0 || index >= size) {
			throw new IndexOutOfBoundsException();
		}
		int bufferIndex = index;
		// correct buffer index from overflow
		for (int i = 0; i < overflowSize; i++) {
			if (overflowIndices[i] == index) {
				return overflowEntries[i];
			} else if (overflowIndices[i] < index) {
				bufferIndex--;
			} else {
				break;
			}
		}
		// determine deleted offset
		// step over flagged indices and adjust buffer index upwards
		// respectively
		for (int hole = holeFlags.nextSetBit(0); hole >= 0
				&& hole <= bufferIndex; hole = holeFlags.nextSetBit(hole + 1)) {
			bufferIndex++;
		}
		// buffer index should now point to the corresponding index
		// within the file buffer, so return it
		return buffer.get(bufferIndex);
	}
135805
public void compact(long index) {
    Map.Entry<Long, JournalSegment<E>> segmentEntry = segments.floorEntry(index);
    if (segmentEntry != null) {
      SortedMap<Long, JournalSegment<E>> compactSegments = segments.headMap(segmentEntry.getValue().index());
      if (!compactSegments.isEmpty()) {
        log.debug("{} - Compacting {} segment(s)", name, compactSegments.size());
        for (JournalSegment segment : compactSegments.values()) {
          log.trace("Deleting segment: {}", segment);
          segment.close();
          segment.delete();
        }
        compactSegments.clear();
        resetHead(segmentEntry.getValue().index());
      }
    }
  }
531510
@Override
    public byte get(int index) {
        Preconditions.checkElementIndex(index, this.length, "index");
        return this.array[index + this.startOffset];
    }
1063801
public function segment($index, $default = null)
	{
		$segments = explode('/', trim($this->getPathInfo(), '/'));

		$segments = array_filter($segments, function($v) { return $v != ''; });

		return array_get($segments, $index - 1, $default);
	}
446388
@Override
    public byte[] get(int index) {
        rangeCheck(index);
        
        try {
            long address = getAddress(index);
            int segPos = _addressFormat.getOffset(address);
            int segInd = _addressFormat.getSegment(address);
            
            // no data found
            if(segPos < Segment.dataStartPosition) return null;
            
            // get data segment
            Segment seg = _segmentManager.getSegment(segInd);
            if(seg == null) return null;
            
            // read data length
            int size = _addressFormat.getDataSize(address);
            int len = (size == 0) ? seg.readInt(segPos) : size;
            
            // read data into byte array
            byte[] data = new byte[len];
            if (len > 0) {
                seg.read(segPos + 4, data);
            }
            
            return data;
        } catch(Exception e) {
            _log.warn(e.getMessage());
            return null;
        }
    }
402848
public function segments(int $index = null)
    {
        $segments = collect(explode('/', $this->path()))
            ->filter(function ($value) {
                return $value !== '';
            })
            ->values()
            ->toArray();

        if (! is_null($index)) {
            return $this->segment($index);
        }

        return $segments;
    }