Returns the last block at least partially contained by the range, or null if no block is contained by the range.
481362
function ( range ) {
    var container = range.endContainer,
        block, child;

    // If inline, get the containing block.
    if ( isInline( container ) ) {
        block = getPreviousBlock( container );
    } else if ( isBlock( container ) ) {
        block = container;
    } else {
        block = getNodeAfter( container, range.endOffset );
        if ( !block ) {
            block = container.ownerDocument.body;
            while ( child = block.lastChild ) {
                block = child;
            }
        }
        block = getPreviousBlock( block );

    }
    // Check the block actually intersects the range
    return block && isNodeContainedInRange( range, block, true ) ? block : null;
}
250259
def extract_control_blocks(head, blocks, cfg)

      # Find the last control block, i.e. the block that has a successor that is not in the loop.
      last_control_block = nil
      blocks.each do |b|
        cfg.successors[b].each do |succ|
          next if blocks.include?(succ)
          # The last control block has to be unique.
          raise StandardError if last_control_block
          last_control_block = b
        end
      end

      # The control block's succesor that is not in the loop is the unique exit block.
      exit_block = cfg.successors[last_control_block].select{|b| !blocks.include?(b)}
      raise StandardError unless exit_block.size == 1

      # In the case of a simple control statement, the last control block is the head block
      # and there are no other control blocks.
      return [last_control_block], exit_block if last_control_block == head

      # If the loop has a complicated control statement, there will be multiple control
      # blocks. Identify them all the way up to the head block.
      work_list = [last_control_block]
      control_blocks = [last_control_block]
      until work_list.empty?
        cfg.predecessors[work_list.shift].each do |pred|
          next if control_blocks.include?(pred)
          next if pred == head && (control_blocks.push(pred) || true)
          control_blocks.push(pred)
          work_list |= [pred]
        end
      end

      return control_blocks, exit_block
    end
564811
bbBlock findBlockForWrite(Object caller, int version, bbBlock curr, int pos)
    {
        assert mutation_in_progress(caller, version);
        assert (pos >= 0 && "invalid position, positions must be >= 0".length() > 0);
        if (pos > this._buf_limit + 1) {
            throw new BlockedBufferException("writes must be contiguous");
        }
        assert _validate();
        if (curr != null && curr.hasRoomToWrite(pos, 1) == true) {
            if (curr._offset + curr._limit == pos && curr._idx < this._next_block_position) {
                bbBlock b = this._blocks.get(curr._idx + 1);
                if (b.containsForWrite(pos)) {
                    curr = b;
                }
            }
            return curr;
        }
        // we're not going to write into curr, so find out the right block
        bbBlock block;
        if (pos == this._buf_limit) {
            // if we're at the limit the only possible (existing) block
            // will be the very last block - shortcut to optimize append
            assert this._next_block_position > 0;
            block = this._blocks.get(this._next_block_position - 1);
        }
        else if (curr != null && pos == curr._offset + curr._limit) {
            // if our current position is exactly at the end (and we already know
            // we can't write into this block if we can write at all we'll have
            // to write into the next block (inner blocks can't be 0 bytes long)
            block = this._blocks.get(curr._idx + 1);
        }
        else {
            // since we're not at the limit and we don't have a current block
            // we'll go find the block in the list (this is an abnormal case)
            // since append if usual for writing
            block = findBlockHelper(pos, 0, this._next_block_position);
        }
        assert block != null;
        assert block.containsForWrite(pos);
        // chech our candidate block to see if it's the one we'd write into
        if (block.hasRoomToWrite(pos, 1)) {
            return block;
        }
        // at this point, we can't use _curr in any event so we can just
        // move on to the next block since findHelper will have returned
        // either the right block (which it didn't) or the one just in
        // front of the right block - so let's see if there is an allocated
        // block just following this
        if (block._idx < this._next_block_position - 1) {
            block = this._blocks.get(block._idx + 1);
            return block;
        }
        // there wasn't a following block (actually a common case when
        // you're appending) so we have to go ahead an actually add a new block
        int newIdx = block._idx + 1;
        assert newIdx == this._next_block_position;
        bbBlock ret =  this.addBlock(caller
                            ,version
                            ,newIdx
                            ,pos
                            ,this.nextBlockSize(caller, version)
               );
        return ret;
    }
1091928
private long getHashPositionOfElement(Block block, int position)
    {
        checkArgument(!block.isNull(position), "position is null");
        int length = block.getSliceLength(position);
        long hashPosition = getMaskedHash(block.hash(position, 0, length));
        while (true) {
            int blockPosition = blockPositionByHash.get(hashPosition);
            if (blockPosition == EMPTY_SLOT) {
                // Doesn't have this element
                return hashPosition;
            }
            else if (elementBlock.getSliceLength(blockPosition) == length && block.equals(position, 0, elementBlock, blockPosition, 0, length)) {
                // Already has this element
                return hashPosition;
            }

            hashPosition = getMaskedHash(hashPosition + 1);
        }
    }
182138
def atlasdb_get_lastblock( con=None, path=None ):
    
    row = None
    with AtlasDBOpen(con=con, path=path) as dbcon:

        sql = "SELECT MAX(block_height) FROM zonefiles;"
        args = ()

        cur = dbcon.cursor()
        res = atlasdb_query_execute( cur, sql, args )

        row = {}
        for r in res:
            row.update(r)
            break

    return row['MAX(block_height)']
1333114
@Override
    public boolean last() throws SQLException {
        checkClosed();
        if (rowCount == 0) {
            return false;
        }
        try {
            if (cursorPosition != Position.middle) {
                cursorPosition = Position.middle;
                table.resetRowPosition();
                table.advanceToRow(0);
            }
            return table.advanceToRow(rowCount - 1);
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
1150635
public static boolean isClosed(final Range<?> range) {
    return range.hasUpperBound() && BoundType.CLOSED.equals(range.upperBoundType())
        && range.hasLowerBound() && BoundType.CLOSED.equals(range.lowerBoundType());
  }
534352
function getBlock() {
  const type = NodeType.BlockType;
  const token = tokens[pos];
  const line = token.ln;
  const column = token.col;
  const end = tokens[pos].right;
  let content = [];

  // Skip `{`.
  pos++;

  while (pos < end) {
    if (checkBlockdecl(pos)) content = content.concat(getBlockdecl());
    else throwError(pos);
  }

  const end_ = getLastPosition(content, line, column, 1);
  pos = end + 1;

  return newNode(type, content, line, column, end_);
}
174139
private static boolean canBeNewCurrInterval(Bound<?> lastBound, Bound<?> currentBound) {
        int vCompare = BoundValueComparator.compareValueDispatchingToInf(lastBound, currentBound);
        if (vCompare != 0) {
            return true;
        } else {
            if (lastBound.isLowerBound() && currentBound.isUpperBound()) {
                return true;
            } else if (lastBound.isUpperBound() && lastBound.getBoundaryType() == RangeBoundary.OPEN 
                && currentBound.isLowerBound() && currentBound.getBoundaryType() == RangeBoundary.OPEN) {
                return true; // the case x) (x
            } else {
                return false;
            }
        }
    }
118993
def range_end(self):
        '''
        '''
        count = self.count
        range_end = self.range_start + self.limit - 1
        if count < range_end:
            range_end = count
        return range_end
784435
@Nullable
    private ScopeBlock findPreviousSiblingScopeBlock(ScopeBlock sb) {
        ScopeBlock parent = sb.getParent();
        if (parent == null) {
            return null;
        }

        List<ScopeBlock> children = parent.getChildren();
        if (children == null) {
            return null;
        }

        ScopeBlock lastSibling = null;
        for (ScopeBlock sibling : children) {
            if (sibling.equals(sb)) {
                return lastSibling;
            }
            lastSibling = sibling;
        }

        return null;
    }
727053
def _find_block_end(self, table, used_cells, block_start, block_end, start_pos, end_pos):
        '''
        
        '''
        table_row = table[block_start[0]]
        used_row = used_cells[block_start[0]]
        table_transpose = TableTranspose(table)

        # Find which column the titles end on
        for column_index in range(block_start[1], end_pos[1] + 1):
            # Ensure we catch the edge case of the data reaching the edge of the table -- block_end
            # should then equal end_pos
            block_end[1] = max(block_end[1], column_index)
            if column_index == end_pos[1]:
                break
            if used_row[column_index]:
                break
            elif is_empty_cell(table_row[column_index]):
                table_column = table_transpose[column_index]
                found_cell = False
                for row_index in range(block_start[0], block_end[0]):
                    if not is_empty_cell(table_column[row_index]):
                        found_cell = True
                        break
                # If we have a column of blanks, stop
                if not found_cell:
                    break
        return block_start, block_end
156130
@Nullable
    private ScopeBlock findScopeBlock(ScopeBlock sb, int pc) {

        if ((pc <= sb.getStart()) || (pc >= sb.getFinish())) {
            return null;
        }

        List<ScopeBlock> children = sb.getChildren();
        if (children != null) {
            for (ScopeBlock child : children) {
                ScopeBlock foundSb = findScopeBlock(child, pc);
                if (foundSb != null) {
                    return foundSb;
                }
            }
        }
        return sb;
    }
789813
private int endCheckBlock()
    {
        Node n;
        int rv = END_DROPS_OFF;

        // check each statment and if the statement can continue onto the next
        // one, then check the next statement
        for (n=first; ((rv & END_DROPS_OFF) != 0) && n != null; n = n.next)
        {
            rv &= ~END_DROPS_OFF;
            rv |= n.endCheck();
        }
        return rv;
    }
1324359
def lastChild(self):
        '''
            
        '''
        blocks = object.__getattribute__(self, 'blocks')
        # First block is empty string for indent, but don't hardcode incase that changes
        if blocks[0] == '':
           firstIdx = 1
        else:
           firstIdx = 0

        if len(blocks) <= firstIdx:
            return None

        return blocks[-1]
50128
public static <T> T last(List<T> lst) {
        if (lst == null || lst.isEmpty()) return null;
        return lst.get(lst.size() - 1);
    }
1246281
public function last($cb=null)
    {
        if ($cb==null) {
            return $this->isNotEmpty()?$this->rows[$this->count()-1]:null;
        } else {
            //method returns the last element in the collection that passes a given truth test:
            $count = $this->count();
            for ($i=0;$i<$count;$i++) {
                if ($cb($this->rows[$count-$i], $count-$i)===true) {
                    return $this->rows[$count-$i];
                }
            }
        }
        return null;
    }