Return start and end positions of the visual selection respectively.
432946
def selection_pos(self):
        """"""
        buff = self._vim.current.buffer
        beg = buff.mark('<')
        end = buff.mark('>')
        return beg, end
504185
function locationOf(element, array, start, end) {
  start = start || 0;
  end = end || array.length;
  var pivot = parseInt(start + (end - start) / 2, 10);
  if (end-start <= 1 || array[pivot] === element) return pivot;
  if (array[pivot] < element) {
    return locationOf(element, array, pivot, end);
  } else {
    return locationOf(element, array, start, pivot);
  }
}
281962
def _keep_selecting(self, event):
        """"""
        canvas = self._canvas
        x = canvas.canvasx(event.x)
        y = canvas.canvasy(event.y)
        canvas.coords(self._sobject,
                      self._sstart[0], self._sstart[1], x, y)
1244554
def selections(self):
        """"""
        selections = []
        cursors = self.cursors()
        if cursors:
            background = self._qpart.palette().color(QPalette.Highlight)
            foreground = self._qpart.palette().color(QPalette.HighlightedText)
            for cursor in cursors:
                selection = QTextEdit.ExtraSelection()
                selection.format.setBackground(background)
                selection.format.setForeground(foreground)
                selection.cursor = cursor

                selections.append(selection)

        return selections
33273
function getNotEmptyNearPositions(board, position) {
    return getNearPositions(board, position).filter(function (p) {
        return Position.hasPiece(p);
    });
}
189885
private ImageDeskew.HoughLine[] getTop(int count) {

        ImageDeskew.HoughLine[] hl = new ImageDeskew.HoughLine[count];
        for (int i = 0; i < count; i++) {
            hl[i] = new ImageDeskew.HoughLine();
        }

        ImageDeskew.HoughLine tmp;

        for (int i = 0; i < (this.cHMatrix.length - 1); i++) {
            if (this.cHMatrix[i] > hl[count - 1].count) {
                hl[count - 1].count = this.cHMatrix[i];
                hl[count - 1].index = i;
                int j = count - 1;
                while ((j > 0) && (hl[j].count > hl[j - 1].count)) {
                    tmp = hl[j];
                    hl[j] = hl[j - 1];
                    hl[j - 1] = tmp;
                    j--;
                }
            }
        }

        int alphaIndex;
        int dIndex;
        
        for (int i = 0; i < count; i++) {
            dIndex = hl[i].index / cSteps; // integer division, no
            // remainder
            alphaIndex = hl[i].index - dIndex * cSteps;
            hl[i].alpha = getAlpha(alphaIndex);
            hl[i].d = dIndex + cDMin;
        }

        return hl;
    }
783417
private int[] selectBestPair( SceneStructureMetric structure ) {
		Se3_F64 w_to_0 = structure.views[0].worldToView;
		Se3_F64 w_to_1 = structure.views[1].worldToView;
		Se3_F64 w_to_2 = structure.views[2].worldToView;

		Se3_F64 view0_to_1 = w_to_0.invert(null).concat(w_to_1,null);
		Se3_F64 view0_to_2 = w_to_0.invert(null).concat(w_to_2,null);
		Se3_F64 view1_to_2 = w_to_1.invert(null).concat(w_to_2,null);

		Se3_F64 candidates[] = new Se3_F64[]{view0_to_1,view0_to_2,view1_to_2};

		int best = -1;
		double bestScore = Double.MAX_VALUE;
		for (int i = 0; i < candidates.length; i++) {
			double s = score(candidates[i]);
			System.out.println("stereo score["+i+"] = "+s);
			if( s < bestScore ) {
				bestScore = s;
				best = i;
			}
		}

		switch (best) {
			case 0: return new int[]{0,1};
			case 1: return new int[]{0,2};
			case 2: return new int[]{1,2};
		}
		throw new RuntimeException("BUG!");
	}
698045
def prepare_selection(self, pos_x, pos_y, width, height):
        
        glSelectBuffer(self.name_counter * 6)
        viewport = glGetInteger(GL_VIEWPORT)

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()

        glRenderMode(GL_SELECT)

        glLoadIdentity()

        if width < 1:
            width = 1
        if height < 1:
            height = 1
        pos_x += width / 2.
        pos_y += height / 2.
        # The system y axis is inverse to the OpenGL y axis
        gluPickMatrix(pos_x, viewport[3] - pos_y + viewport[1], width, height, viewport)

        self._apply_orthogonal_view()
525367
def selection_ranges(self):
        
        if self.selection:
            from_, to = sorted([self.cursor_position, self.selection.original_cursor_position])

            if self.selection.type == SelectionType.BLOCK:
                from_line, from_column = self.translate_index_to_position(from_)
                to_line, to_column = self.translate_index_to_position(to)
                from_column, to_column = sorted([from_column, to_column])
                lines = self.lines

                for l in range(from_line, to_line + 1):
                    line_length = len(lines[l])
                    if from_column < line_length:
                        yield (self.translate_row_col_to_index(l, from_column),
                               self.translate_row_col_to_index(l, min(line_length - 1, to_column)))
            else:
                # In case of a LINES selection, go to the start/end of the lines.
                if self.selection.type == SelectionType.LINES:
                    from_ = max(0, self.text.rfind('\n', 0, from_) + 1)

                    if self.text.find('\n', to) >= 0:
                        to = self.text.find('\n', to)
                    else:
                        to = len(self.text) - 1

                yield from_, to
139848
function getAllNearPositions(position) {
    return [[-1, -1], [0, -1], [1, -1], [-1, 0], [1, 0], [-1, 1], [0, 1], [1, 1] // Below positions
    ].map(function (toAdd) {
        return {
            x: position.x + toAdd[0],
            y: position.y + toAdd[1]
        };
    });
}
474829
function (start, end, pos, complete) {
		var ret = [],
			i = start.length,
			startVal;

		if (pos === 1) { // land on the final path without adjustment points appended in the ends
			ret = complete;

		} else if (i === end.length && pos < 1) {
			while (i--) {
				startVal = parseFloat(start[i]);
				ret[i] =
					isNaN(startVal) ? // a letter instruction like M or L
						start[i] :
						pos * (parseFloat(end[i] - startVal)) + startVal;

			}
		} else { // if animation is finished or length not matching, land on right value
			ret = end;
		}
		return ret;
	}
671687
private void selectionSort(final T[] array, int start, int end, Comparator<T> lt) {
    int i;
    int j;
    int bestI;
    T tmp;
    for (i = start; i < end; i++) {
      bestI = i;
      for (j = i + 1; j < end; j++) {
        if (lt.compare(array[j], array[bestI]) < 0)
          bestI = j;
      }
      tmp = array[i];
      array[i] = array[bestI];
      array[bestI] = tmp;
    }
  }
1298560
def get_elementary_intervals(self, features):
        """"""
        coords = []
        try:
            for interval in features:
                if len(interval) != 3:
                    raise SyntaxError('Interval malformed %s. Allways specify start and end position for interval.' % str(interval))
                coords.extend([interval[0],interval[1]])    
        except IndexError:
            raise SyntaxError('Interval malformed %s. Allways specify start and end position for interval.' % str(interval))
        coords = list(set(coords))
        coords.sort()
        return coords
48707
function _getRectangleImageCoordinates(startHandle, endHandle) {
  return {
    left: Math.min(startHandle.x, endHandle.x),
    top: Math.min(startHandle.y, endHandle.y),
    width: Math.abs(startHandle.x - endHandle.x),
    height: Math.abs(startHandle.y - endHandle.y),
  };
}
1341340
def select_coords(self):
        
        start, stop = self.start, self.stop
        nrows = self.table.nrows
        if start is None:
            start = 0
        elif start < 0:
            start += nrows
        if self.stop is None:
            stop = nrows
        elif stop < 0:
            stop += nrows

        if self.condition is not None:
            return self.table.table.get_where_list(self.condition.format(),
                                                   start=start, stop=stop,
                                                   sort=True)
        elif self.coordinates is not None:
            return self.coordinates

        return np.arange(start, stop)
1239674
function Selection (start, end, caret) {
		/**
		 * The selection start offset.
		 *
		 * @name orion.editor.Selection#start
		 */
		this.start = start;
		/**
		 * The selection end offset.
		 *
		 * @name orion.editor.Selection#end
		 */
		this.end = end;
		/** @private */
		this.caret = caret; //true if the start, false if the caret is at end
		/** @private */
		this._columnX = -1;
	}
1268789
def __restore_selection(self, start_pos, end_pos):
        """"""
        cursor = self.textCursor()
        cursor.setPosition(start_pos)
        cursor.setPosition(end_pos, QTextCursor.KeepAnchor)
        self.setTextCursor(cursor)