get int from segments.

@param segments target segments.
@param offset value offset.
545971
public static int getInt(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 4)) {
			return segments[0].getInt(offset);
		} else {
			return getIntMultiSegments(segments, offset);
		}
	}
956044
protected void checkOffset(long offset) {
    if (offset(offset) < this.offset) {
      throw new IndexOutOfBoundsException();
    } else if (limit == -1) {
      if (offset > maxCapacity)
        throw new IndexOutOfBoundsException();
    } else {
      if (offset > limit)
        throw new IndexOutOfBoundsException();
    }
  }
569908
private void clean(int from, int to) {
        for (int i = from; i < to; i++) {
            ByteBuffer bb = segments.get(i);
            cleanMappedByteBuffer(bb);
            segments.set(i, null);
        }
    }
1289573
public static int hash(MemorySegment[] segments, int offset, int numBytes) {
		if (inFirstSegment(segments, offset, numBytes)) {
			return MurmurHashUtil.hashBytes(segments[0], offset, numBytes);
		} else {
			return hashMultiSeg(segments, offset, numBytes);
		}
	}
582741
@Pure
	@SuppressWarnings("checkstyle:cyclomaticcomplexity")
	public PT getStartingPointFor(int index) {
		if ((index < 1) || (this.segmentList.size() <= 1)) {
			if (this.startingPoint != null) {
				return this.startingPoint;
			}
		} else {
			int idx = index;
			ST currentSegment = this.segmentList.get(idx);
			ST previousSegment = this.segmentList.get(--idx);

			// Because the two segments are the same
			// we must go deeper in the path elements
			// to detect the right segment
			int count = 0;
			while ((previousSegment != null) && (previousSegment.equals(currentSegment))) {
				currentSegment = previousSegment;
				idx--;
				previousSegment = (idx >= 0) ? this.segmentList.get(idx) : null;
				count++;
			}

			if (count > 0) {
				PT sp = null;
				if (previousSegment != null) {
					final PT p1 = currentSegment.getBeginPoint();
					final PT p2 = currentSegment.getEndPoint();
					final PT p3 = previousSegment.getBeginPoint();
					final PT p4 = previousSegment.getEndPoint();

					assert p1 != null && p2 != null && p3 != null && p4 != null;
					if (p1.equals(p3) || p1.equals(p4)) {
						sp = p1;
					} else if (p2.equals(p3) || p2.equals(p4)) {
						sp = p2;
					}

				} else {
					sp = this.startingPoint;
				}
				if (sp != null) {
					return ((count % 2) == 0) ? sp : currentSegment.getOtherSidePoint(sp);
				}

			} else if ((currentSegment != null) && (previousSegment != null)) {
				// if the two segments are different
				// it is simple to detect the
				// common point
				final PT p1 = currentSegment.getBeginPoint();
				final PT p2 = currentSegment.getEndPoint();
				final PT p3 = previousSegment.getBeginPoint();
				final PT p4 = previousSegment.getEndPoint();

				assert p1 != null && p2 != null && p3 != null && p4 != null;
				if (p1.equals(p3) || p1.equals(p4)) {
					return p1;
				}
				if (p2.equals(p3) || p2.equals(p4)) {
					return p2;
				}
			}
		}

		return null;
	}
125834
function(t) {

            var segments = this.segments;
            var numSegments = segments.length;
            if (numSegments === 0) return null; // if segments is an empty array

            var segmentIndex = t.segmentIndex;
            if (segmentIndex < 0) return segments[0].pointAtT(0);
            if (segmentIndex >= numSegments) return segments[numSegments - 1].pointAtT(1);

            var tValue = t.value;
            if (tValue < 0) tValue = 0;
            else if (tValue > 1) tValue = 1;

            return segments[segmentIndex].pointAtT(tValue);
        }
756583
@Override
	public final void get(DataOutput out, int offset, int length) throws IOException {
		if (address <= addressLimit) {
			if (heapMemory != null) {
				out.write(heapMemory, offset, length);
			}
			else {
				while (length >= 8) {
					out.writeLong(getLongBigEndian(offset));
					offset += 8;
					length -= 8;
				}

				while (length > 0) {
					out.writeByte(get(offset));
					offset++;
					length--;
				}
			}
		}
		else {
			throw new IllegalStateException("segment has been freed");
		}
	}
1006258
@Override
  protected Long boundaryForSegment(String segmentName) throws IOException {
    if (segmentRegistration.equals(SEGMENT_SORT_ASC)
        || segmentRegistration.equals(SEGMENT_SORT_DESC)) {
      Long thisLast = segmentValueTopListLast.get(segmentName);
      if (thisLast == null) {
        return null;
      } else if (segmentRegistration.equals(SEGMENT_SORT_ASC)) {
        return thisLast * segmentNumber;
      } else {
        return Math.floorDiv(thisLast, segmentNumber);
      }
    } else {
      throw new IOException("can't compute boundary for segmentRegistration "
          + segmentRegistration);
    }
  }
1043669
public static double getDouble(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 8)) {
			return segments[0].getDouble(offset);
		} else {
			return getDoubleMultiSegments(segments, offset);
		}
	}
636641
public static void setLong(MemorySegment[] segments, int offset, long value) {
		if (inFirstSegment(segments, offset, 8)) {
			segments[0].putLong(offset, value);
		} else {
			setLongMultiSegments(segments, offset, value);
		}
	}
1217261
@SuppressWarnings("unchecked")
    public T get(long index)
    {
        return (T) array[segment(index)][offset(index)];
    }
866154
@Pure
	public int lastIndexOf(RoadSegment segment) {
		int count = 0;
		int index;
		int lastIndex = -1;
		for (final RoadPath p : this.paths) {
			index = p.lastIndexOf(segment);
			if (index >= 0) {
				lastIndex = count + index;
			}
			count += p.size();
		}
		return lastIndex;
	}
1091825
public void setSegments(java.util.Collection<Segment> segments) {
        if (segments == null) {
            this.segments = null;
            return;
        }

        this.segments = new java.util.ArrayList<Segment>(segments);
    }
899427
@Override
  protected Double boundaryForSegmentComputing(String segmentName)
      throws IOException {
    if (segmentRegistration.equals(SEGMENT_SORT_ASC)
        || segmentRegistration.equals(SEGMENT_SORT_DESC)) {
      Double boundary = boundaryForSegment(segmentName);
      if (boundary == null) {
        return null;
      } else {
        if (segmentRegistration.equals(SEGMENT_SORT_DESC)) {
          long correctionBoundary = 0;
          for (String otherSegmentName : segmentValueTopListLast.keySet()) {
            if (!otherSegmentName.equals(segmentName)) {
              Double otherBoundary = segmentValuesBoundary
                  .get(otherSegmentName);
              if (otherBoundary != null) {
                correctionBoundary += Math.max(0, otherBoundary - boundary);
              }
            }
          }
          return boundary + correctionBoundary;
        } else {
          return boundary;
        }
      }
    } else {
      throw new IOException("can't compute boundary for segmentRegistration "
          + segmentRegistration);
    }
  }
145686
public static short getShort(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 2)) {
			return segments[0].getShort(offset);
		} else {
			return getShortMultiSegments(segments, offset);
		}
	}
303464
public static char getChar(MemorySegment[] segments, int offset) {
		if (inFirstSegment(segments, offset, 2)) {
			return segments[0].getChar(offset);
		} else {
			return getCharMultiSegments(segments, offset);
		}
	}
764189
static int getInt(byte[] buffer, int offset) {
        return buffer[offset] << 24 | (buffer[offset + 1] & 0xff) << 16 | (buffer[offset + 2] & 0xff) << 8
                | (buffer[offset + 3] & 0xff);
    }