Prints the coordinates to the underlying stream. One index pair on each
line. The offset is added to each index, typically, this can transform
from a 0-based indicing to a 1-based.
182187
public void printPattern(int[] row, int[] column, int offset) {
        int size = row.length;
        if (size != column.length)
            throw new IllegalArgumentException(
                    "All arrays must be of the same size");
        for (int i = 0; i < size; ++i)
            format(Locale.ENGLISH, "%10d %10d%n", row[i] + offset, column[i]
                    + offset);
    }
910066
function(offset) {
        var index = this._indexArray,
            l = this.index_pointer;
        index[0 + l] = 0 + offset;
        index[1 + l] = 1 + offset;
        index[2 + l] = 2 + offset;
        index[3 + l] = 1 + offset;
        index[4 + l] = 2 + offset;
        index[5 + l] = 3 + offset;
        this.index_pointer += 6;
    }
363329
public static int getDelimiterOffset(final String line, final int start, final char delimiter) {
        int idx = line.indexOf(delimiter, start);
        if (idx >= 0) {
            idx -= start - 1;
        }
        return idx;
    }
973882
function print(str, indent, inline) {
                var lines = str.split("\n");

                for (var i = 0; i < lines.length; i++) {
                    if (lines[i]) {
                        if ((inline && i > 0) || !inline) {
                            for (var j = 0; j < indent; j++) {
                                util.print(" ");
                            }
                        }
                    }

                    if (i === lines.length - 1) {
                        util.print(lines[i]);
                    } else {
                        util.puts(lines[i]);
                    }
                }
            }
538854
static OffsetIndex buildOffsetIndex(ByteSource source) throws IOException {
    final Map<Symbol, OffsetRange<ByteOffset>> ret = Maps.newHashMap();

    // we could be more efficient and deal with the byte stream as it comes along,
    // but these files don't exceed 50 MB, so it's simpler just to read it all in
    final byte[] fileAsBytes = source.read();

    // Okay, kids, don't try this at home. In general searching byte-by-byte through UTF-8 is a
    // bad idea, because multibyte characters will trip you up.  However, in this particular case:
    //   (a) all of the characters in our search strings are single-byte, and
    //   (b) for the begin and end probes, they are long enough that the chances of them occurring
    //         accidentally starting at a non-initial character of a multibyte character
    //         is vanishingly small.  It could be a problem for docIdEnd, being only a single character,
    //         but this will only be a problem if we have non-ASCII unicode characters in the doc IDs
    //         which is not the case for Gigaword.
    int startDocInclusive;
    int nextSearchIdx = 0;
    while ((startDocInclusive = findBytes(fileAsBytes, beginProbe, nextSearchIdx)) != NOT_FOUND) {
      final int startDocIDInclusive = startDocInclusive + beginProbe.length; // double check this!
      final int endDocIDIdxExclusive = findBytes(fileAsBytes, docIdEnd, startDocIDInclusive + 1);
      if (endDocIDIdxExclusive != NOT_FOUND) {
        final String docID = bytesAsString(fileAsBytes, startDocIDInclusive, endDocIDIdxExclusive);
        final int endTagIdx = findBytes(fileAsBytes, endProbe, endDocIDIdxExclusive + 1);
        if (endTagIdx != NOT_FOUND) {
          final int endDocIdxInclusive = endTagIdx + endProbe.length - 1;
          if (ret.containsKey(Symbol.from(docID))) {
            log.warn("Document ID {} occurs more than once; using latest version", docID);
          }
          ret.put(Symbol.from(docID),
              OffsetRange.byteOffsetRange(startDocInclusive, endDocIdxInclusive));
          nextSearchIdx = endDocIdxInclusive + 1;
        } else {
          throw new IOException("Failed to find closing document tag in " + source);
        }
      } else {
        throw new IOException("Failed to find end of document ID in " + source);
      }
    }
    return OffsetIndices.forMap(ret);
  }
727983
private void printSpaces(int count, java.io.PrintStream out) {
        for (int i = 0; i < count; i++) {
            out.print(" ");
        }
    }
987864
void addPoint(GraphicPoint offPt, int i_src) {
		if (m_offsetPtCount == 0) // TODO: can we have this outside of this
									// method?
		{
			addPoint(offPt);
			return;
		}

		int n_src = m_srcPtCount;
		GraphicPoint pt1, pt;
		pt1 = m_srcPts.get(i_src == 0 ? n_src - 1 : i_src - 1);
		pt = m_srcPts.get(i_src);

		// calculate scalar product to determine if the offset segment goes in
		// the same/opposite direction compared to the original one
		double s = scal(pt1, pt, m_offsetPts.get(m_offsetPtCount - 1), offPt);
		if (s > 0)
		// original segment and offset segment go in the same direction. Just
		// add the point
		{
			addPoint(offPt);
			return;
		}

		if (s < 0) {
			// we will add a loop. We need to make sure the points we introduce
			// don't generate a "reversed" segment
			// let's project the first point of the reversed segment
			// (m_offsetPts + m_offsetPtCount - 1) to check
			// if it falls on the good side of the original segment (scalar
			// product sign again)
			if (scal(pt1, pt, pt, m_offsetPts.get(m_offsetPtCount - 1)) > 0) {
				GraphicPoint p;

				// change value of m_offsetPts + m_offsetPtCount - 1
				int k;
				if (i_src == 0)
					k = n_src - 2;
				else if (i_src == 1)
					k = n_src - 1;
				else
					k = i_src - 2;
				GraphicPoint pt0 = m_srcPts.get(k);

				double a = Math.atan2(pt1.y - pt0.y, pt1.x - pt0.x);
				p = new GraphicPoint(pt1, m_distance, a - half_pi);
				m_offsetPts.set(m_offsetPtCount - 1, p);

				if (m_joins == OperatorOffset.JoinType.Bevel
						|| m_joins == OperatorOffset.JoinType.Miter) {
					// this block is added as well as the commented BAD_SEG in
					// the next block
					p = new GraphicPoint(p, pt1);
					addPoint(p);

					// "bad" segment
					p = new GraphicPoint(pt1, m_distance, m_a1 + half_pi);

					GraphicPoint p_ = new GraphicPoint(p, pt1);
					p_.type |= BAD_SEG;
					addPoint(p_);

					addPoint(p);
				} else {
					// the working stuff for round and square

					// "bad" segment
					p = new GraphicPoint(pt1, m_distance, m_a1 + half_pi);
					p.type |= BAD_SEG;
					addPoint(p);
				}

				// add offPt
				addPoint(offPt, i_src);
			} else {
				GraphicPoint p;

				// we don't add offPt but the loop containing the "bad" segment
				p = new GraphicPoint(pt, m_distance, m_a1 + half_pi);
				addPoint(p);

				if (m_joins == OperatorOffset.JoinType.Bevel
						|| m_joins == OperatorOffset.JoinType.Miter) {
					// this block is added as well as the commented BAD_SEG in
					// the next block
					p = new GraphicPoint(p, pt);
					addPoint(p);

					p = new GraphicPoint(pt, m_distance, m_a2 - half_pi);
					GraphicPoint p_ = new GraphicPoint(p, pt);
					p_.type |= BAD_SEG;
					addPoint(p_);

					addPoint(p);
				} else {
					// the working stuff for round and square
					p = new GraphicPoint(pt, m_distance, m_a2 - half_pi);
					p.type |= BAD_SEG;
					addPoint(p);
				}
			}
		}
	}
984486
def index_each_line
        positions = []
        size = 0
        each_line do |line|
          positions << [size, line.size]
          size += line.size
        end
        rewind
        positions
      end
797053
void compressOffsetArray(int i0) {
		int i_ = i0;
		while (m_offsetPts.get(i_).m_prev < i_)
			i_ = m_offsetPts.get(i_).m_prev;

		int j = 0, i = i_;

		do {
			GraphicPoint pt = m_offsetPts.get(i);
			m_offsetPts.set(j, pt);
			i = pt.m_next;
			j++;
		} while (i != i_);

		m_offsetPts.set(j, m_offsetPts.get(0)); // duplicate closing point

		m_offsetPtCount = j + 1;
	}
220802
static void writeOffset(ZoneOffset offset, DataOutput out) throws IOException {
        final int offsetSecs = offset.getTotalSeconds();
        int offsetByte = offsetSecs % 900 == 0 ? offsetSecs / 900 : 127;  // compress to -72 to +72
        out.writeByte(offsetByte);
        if (offsetByte == 127) {
            out.writeInt(offsetSecs);
        }
    }
1174789
public void offsetTo(float newLeft, float newTop) {
        right += newLeft - left;
        bottom += newTop - top;
        left = newLeft;
        top = newTop;
    }
680715
public Stream<IntPair> adjacent4Points(final int i, final int j) {
        final IntPair up = i == 0 ? null : IntPair.of(i - 1, j);
        final IntPair right = j == cols - 1 ? null : IntPair.of(i, j + 1);
        final IntPair down = i == rows - 1 ? null : IntPair.of(i + 1, j);
        final IntPair left = j == 0 ? null : IntPair.of(i, j - 1);

        return Stream.of(up, right, down, left);
    }
1303190
public void printCoordinate(int[] row, int[] column, float[] dataR,
            float[] dataI) {
        printCoordinate(row, column, dataR, dataI, 0);
    }
156964
private void addVertex(String data)
	{
		String coords[] = data.split("\\s+");
		float x = 0;
		float y = 0;
		float z = 0;
		if (coords.length != 3)
		{
			MalisisCore.log.error("[ObjFileImporter] Wrong coordinates number {} at line {} : {}", coords.length, lineNumber, currentLine);
		}
		else
		{
			x = Float.parseFloat(coords[0]);
			y = Float.parseFloat(coords[1]);
			z = Float.parseFloat(coords[2]);
		}

		vertexes.add(new Vertex(x, y, z));
	}
1030647
private int cpReadUnsignedShort(final int cpIdx) throws IOException {
        if (cpIdx < 1 || cpIdx >= cpCount) {
            throw new ClassfileFormatException("Constant pool index " + cpIdx + ", should be in range [1, "
                    + (cpCount - 1) + "] -- cannot continue reading class. "
                    + "Please report this at https://github.com/classgraph/classgraph/issues");
        }
        return inputStreamOrByteBuffer.readUnsignedShort(entryOffset[cpIdx]);
    }
520933
public static void readFully(Reader reader, char[] buffer, int offset) throws IOException {
    int originalOffset = offset;
    int expected = buffer.length - offset;
    while (offset < buffer.length) {
      int numRead = reader.read(buffer, offset, buffer.length - offset);
      if (numRead < 0) {
        throw new IOException(
                String.format("Reached end of stream earlier than expected. Expected to read %d bytes. Actual: %d",
                expected, offset - originalOffset));
      }
      offset += numRead;
    }
  }
632091
private static PrintStream openStream(File out) throws IOException {
    OutputStream os = new FileOutputStream(out);
    os = out.getName().endsWith(GZIP_POSTFIX) ? new GZIPOutputStream(os) : os;
    return new PrintStream(os);
  }