/*
Compute and validate the offsets of the fields in the list and will set the fields computedOffset.
Will validate the blockLength of the fields encompassing &lt;message&gt; or &lt;group&gt; and recursively
descend into repeated groups.
2741
private static int computeAndValidateOffsets(final Node node, final List<Field> fields, final int blockLength)
    {
        boolean variableLengthBlock = false;
        int offset = 0;

        for (final Field field : fields)
        {
            if (0 != field.offset() && field.offset() < offset)
            {
                handleError(node, "Offset provides insufficient space at field: " + field.name());
            }

            if (Token.VARIABLE_LENGTH != offset)
            {
                if (0 != field.offset())
                {
                    offset = field.offset();
                }
                else if (null != field.dimensionType() && 0 != blockLength)
                {
                    offset = blockLength;
                }
                else if (field.isVariableLength() && 0 != blockLength)
                {
                    offset = blockLength;
                }
            }

            field.computedOffset(variableLengthBlock ? Token.VARIABLE_LENGTH : offset);

            if (null != field.groupFields())
            {
                final int groupBlockLength = computeAndValidateOffsets(node, field.groupFields(), 0);

                validateBlockLength(node, field.blockLength(), groupBlockLength);
                field.computedBlockLength(Math.max(field.blockLength(), groupBlockLength));

                variableLengthBlock = true;
            }
            else if (null != field.type() && Presence.CONSTANT != field.presence())
            {
                final int size = field.type().encodedLength();

                if (Token.VARIABLE_LENGTH == size)
                {
                    variableLengthBlock = true;
                }
                else
                {
                    field.computedBlockLength(size);
                }

                if (!variableLengthBlock)
                {
                    offset += size;
                }
            }
        }

        return offset;
    }
746009
function calculateOffsetLeft(obj)
{
	var curleft = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		while (obj = obj.offsetParent) 
			curleft += obj.offsetLeft;
	} else if (obj.x)
		curleft += obj.x;
	return curleft;
}
149603
@Override
    public void getOffset(long date, boolean local, int[] offsets) {
        synchronized (javacal) {
            if (local) {
                int fields[] = new int[6];
                Grego.timeToFields(date, fields);
                int hour, min, sec, mil;
                int tmp = fields[5];
                mil = tmp % 1000;
                tmp /= 1000;
                sec = tmp % 60;
                tmp /= 60;
                min = tmp % 60;
                hour = tmp / 60;
                javacal.clear();
                javacal.set(fields[0], fields[1], fields[2], hour, min, sec);
                javacal.set(java.util.Calendar.MILLISECOND, mil);

                int doy1, hour1, min1, sec1, mil1;
                doy1 = javacal.get(java.util.Calendar.DAY_OF_YEAR);
                hour1 = javacal.get(java.util.Calendar.HOUR_OF_DAY);
                min1 = javacal.get(java.util.Calendar.MINUTE);
                sec1 = javacal.get(java.util.Calendar.SECOND);
                mil1 = javacal.get(java.util.Calendar.MILLISECOND);

                if (fields[4] != doy1 || hour != hour1 || min != min1 || sec != sec1 || mil != mil1) {
                    // Calendar field(s) were changed due to the adjustment for non-existing time
                    // Note: This code does not support non-existing local time at year boundary properly.
                    // But, it should work fine for real timezones.
                    int dayDelta = Math.abs(doy1 - fields[4]) > 1 ? 1 : doy1 - fields[4];
                    int delta = ((((dayDelta * 24) + hour1 - hour) * 60 + min1 - min) * 60 + sec1 - sec) * 1000 + mil1 - mil;

                    // In this case, we use the offsets before the transition
                   javacal.setTimeInMillis(javacal.getTimeInMillis() - delta - 1);
                }
            } else {
                javacal.setTimeInMillis(date);
            }
            offsets[0] = javacal.get(java.util.Calendar.ZONE_OFFSET);
            offsets[1] = javacal.get(java.util.Calendar.DST_OFFSET);
        }
    }
359316
function(field, length) {
    if (Array.isArray(field)) {
      return this.validateFieldsHelper(field, [length], this.validatesLengthOf)
    }

    return this.validates(field, function() {
      var valid = true
      if (this[field]) valid = this[field].length <= length
      if (!valid)
        this.errors.add(field, 'maximum length of ' + length + ' exceeded')
      return valid
    })
  }
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;
    }
697442
private long[] createSparseOffsets(long offset) {

        // resolve the offsets in the view dimension
        int underlyingRank = sparseOffsets().length;
        long[] newOffsets = new long[rank()];
        List<Long> shapeList = Longs.asList(shape());
        int penultimate = rank() - 1;
        for (int i = 0; i < penultimate; i++) {
            long prod = ArrayUtil.prodLong(shapeList.subList(i + 1, rank()));
            newOffsets[i] = offset / prod;
            offset = offset - newOffsets[i] * prod;
        }
        newOffsets[rank() - 1] = offset % shape()[rank() - 1];

        // Merge the offsets with the original sparseOffsets
        long[] finalOffsets = new long[underlyingRank];
        int dimNotFixed = 0;
        for (int dim = 0; dim < underlyingRank; dim++) {
            if (flags()[dim] == 1) {
                finalOffsets[dim] = sparseOffsets()[dim];
            } else {
                finalOffsets[dim] = newOffsets[dimNotFixed] + sparseOffsets()[dim];
                dimNotFixed++;
            }
        }
        return finalOffsets;
    }
850066
private long mappingOffset() {
        int ps = Bits.pageSize();
        long offset = address % ps;
        return (offset >= 0) ? offset : (ps + offset);
    }
914791
function (node) {
        if (node.properties.length === 0) {
          return
        }

        var first = context.getFirstToken(node)
        var second = context.getFirstToken(node, 1)
        var penultimate = context.getLastToken(node, 1)
        var last = context.getLastToken(node)

        validateBraceSpacing(node, first, second, penultimate, last)
      }
480822
function getOffsetValues(start, length, correction) {
    var adapter = this.adapter;
    var values = [];

    correction += (start * 2); // offset the positioning query

    for (var i = 0; i < length; i++) {
      values.push(adapter.at((i * 2) + correction));
    }

    return values;
  }
54125
public List<Long> getOffsets(OffsetRequest offsetRequest) {
        ILog log = getLog(offsetRequest.topic, offsetRequest.partition);
        if (log != null) {
            return log.getOffsetsBefore(offsetRequest);
        }
        return ILog.EMPTY_OFFSETS;
    }
189659
function processMaybeBlock(node, baseToken) {
            const firstToken = getFirstAndLastTokens(node).firstToken
            setOffsetToToken(
                firstToken,
                isLeftBrace(firstToken) ? 0 : 1,
                baseToken
            )
        }
1080896
public boolean containsInstructionWithOffset(int offset) {
        Iterator<InstructionHandle> i = instructionIterator();
        while (i.hasNext()) {
            if (i.next().getPosition() == offset) {
                return true;
            }
        }
        return false;
    }
888654
function verifyAlignment(node) {
            createGroups(node).forEach(group => {
                verifyGroupAlignment(group.filter(isKeyValueProperty));
            });
        }
1224575
public function offsetSet($offset, $value) {
		if(is_null($offset))
			$this->fields[] = $this->parseFields($value, count($this->fields));
		else
			$this->fields[$offset] = $this->parseFields($value, $offset);
	}
657513
public function offsetSet($offset, $value): void
    {
        self::validateOffset($offset);
        $this->data[$offset] = $value;
    }
280803
function fromOffsetPath(ancestor, offsets) {
  let current = ancestor;
  for (let i = 0, len = offsets.length; i < len; i++) {
    if (current.childNodes.length <= offsets[i]) {
      current = current.childNodes[current.childNodes.length - 1];
    } else {
      current = current.childNodes[offsets[i]];
    }
  }
  return current;
}
898364
void getBlock(int offset) {

        try {
            RowSetNavigatorClient source = session.getRows(id, offset,
                baseBlockSize);

            table         = source.table;
            currentOffset = source.currentOffset;
        } catch (HsqlException e) {}
    }