Make/maintain a linked list of the indexes of left siblings and their lowest vertical coordinate.
331442
function updateIYL(minY, i, ih) {
    // Remove siblings that are hidden by the new subtree.  
    while (ih != null && minY >= ih.lowY) ih = ih.nxt;                 
    // Prepend the new subtree.  
    return {
      lowY: minY, 
      index: i, 
      nxt: ih,
    };                                       
  }
200154
def __sort_adjacency_lists(dfs_data):
    """"""
    new_adjacency_lists = {}

    adjacency_lists = dfs_data['adj']
    edge_weights = dfs_data['edge_weights']
    edge_lookup = dfs_data['edge_lookup']

    for node_id, adj_list in list(adjacency_lists.items()):
        node_weight_lookup = {}
        frond_lookup = {}
        for node_b in adj_list:
            edge_id = dfs_data['graph'].get_first_edge_id_by_node_ids(node_id, node_b)
            node_weight_lookup[node_b] = edge_weights[edge_id]
            frond_lookup[node_b] = 1 if edge_lookup[edge_id] == 'backedge' else 2

        # Fronds should be before branches if the weights are equal
        new_list = sorted(adj_list, key=lambda n: frond_lookup[n])

        # Sort by weights
        new_list.sort(key=lambda n: node_weight_lookup[n])

        # Add the new sorted list to the new adjacency list lookup table
        new_adjacency_lists[node_id] = new_list

    return new_adjacency_lists
1302245
def __get_lowpoints(node, dfs_data):
    """"""

    ordering_lookup = dfs_data['ordering_lookup']

    t_u = T(node, dfs_data)
    sorted_t_u = sorted(t_u, key=lambda a: ordering_lookup[a])
    lowpoint_1 = sorted_t_u[0]
    lowpoint_2 = sorted_t_u[1]

    return lowpoint_1, lowpoint_2
394503
List<Integer> constructShareRing(Map<Integer, List<Integer>> treeMap,
                                            Map<Integer, Integer> parentMap,
                                            int rank) {
        Set<Integer> connectionSet = new LinkedHashSet<>(treeMap.get(rank));
        connectionSet.remove(parentMap.get(rank));
        if(connectionSet.isEmpty()) {
            return Collections.singletonList(rank);
        } else {
            List<Integer> ringSeq = new LinkedList<>();
            ringSeq.add(rank);
            int cnt = 0;
            for(Integer n : connectionSet) {
                List<Integer> vConnSeq = constructShareRing(treeMap, parentMap, n);
                cnt++;
                if(connectionSet.size() == cnt) {
                    Collections.reverse(vConnSeq);
                }
                ringSeq.addAll(vConnSeq);
            }
            return ringSeq;
        }

    }
129284
public S setAfter(int leftIndex) {
		return set(Indexer.of(delegate.get()).after(leftIndex));
	}
972115
private void leftFringe(
    DeleteStack.Linearizer       lxx,
    DeleteStack.FringeNote      xx,
    InsertStack   istack,
    GBSNode       f,
    GBSNode       g,
    boolean       gLeft,
    int           t0_depth)
  {

    GBSNode w = f.rightChild();    /* The right brother of delete fringe    */
    GBSNode s = f.leftChild();     /* t0 fringe from which we deleted       */
    GBSNode bfather = g;
    GBSNode sh = null;             /* The linearized s                      */
    GBSNode p = null;
    int fbalance = f.balance();
    f.clearBalance();
    if (w == null)                 /* There is no right brother             */
      {
        sh = linearize(lxx, s);
        f.setRightChild(null);
        combine(lastInList(sh), f);/* [s, f]                                */
        p = sh;
        xx.depthDecrease = true;
      }
    else                           /* There is a right brother              */
      {
        p = linearize(lxx, s);
        f.setChildren(null, null);
        combine(lastInList(p), f); /* [s, f]                                */
        sh = p;                    /* Assume linear list or single t0       */
        GBSNode wh = w.leftMostChild(istack);
        int zpoints = istack.index();
        if (zpoints > 0)           /* Is a t0 fringe (possibly more         */
          {                        /*  than one level down)                 */
            zpoints--;
            int ztop = 0;          /* Assume top of entire tree             */
            if (zpoints >= t0_depth)/* Have more than a whole t0 fringe     */
              {
                ztop = zpoints - t0_depth + 1;
                sh = w;            /* We will elevate w                     */
                bfather = istack.node(ztop-1);
                bfather.setLeftChild(p);/* Father of left-most fringe       */
                                   /*        points to linear list          */
              }
                                   /* Linearize left-most fringe            */
          wh = linearize(lxx, istack.node(ztop));
          }
        combine(lastInList(p), wh);/* Add w onto f  (now [s, f, w])         */
        leftDepth(xx, fbalance);   /* Check for depth change                */
      }
    if (gLeft) {
      g.setLeftChild(sh);
    }
    else {
      g.setRightChild(sh);
    }
    boolean bLeft = true;
    if (bfather.rightChild() == p) {
      bLeft = false;
    }
    int maxBal = g.kFactor() - 1;
    if (maxBal < 3) {
      maxBal = 3;
    }
    istack.start(bfather, "GBSDeleteFringe.leftFringe");
    istack.setNode(1, null);
    istack.resetBalancePointIndex();
    int fpidx = 1;
    if (g.kFactor() > 2) {
      GBSInsertFringe.singleInstance().balance(
                      g.kFactor(), istack, p, fpidx, maxBal);
    }
    xx.newg = bfather;
    if (bLeft) {
      xx.newf = bfather.leftChild();
    }
    else {
      xx.newf = bfather.rightChild();
    }
  }
832345
private void quicksort(short[] a, int[] indexes, int left, int right) {
        if (right <= left)
            return;
        int i = partition(a, indexes, left, right);
        quicksort(a, indexes, left, i - 1);
        quicksort(a, indexes, i + 1, right);
    }
259115
public static ArrayList<Integer> getSiblingsOf(int[] parents, int idx) {
        int parent = parents[idx];
        ArrayList<Integer> siblings = new ArrayList<Integer>();
        for (int i=0; i<parents.length; i++) {
            if (parents[i] == parent) {
                siblings.add(i);
            }
        }
        return siblings;
    }
812738
private void moveIndexesToNextCombination()
    {
        for (int i = currentIndexes.length - 1, j = list.size() - 1; i >= 0; i--, j--)
        {
            if (currentIndexes[i] != j)
            {
                currentIndexes[i]++;
                for (int k = i + 1; k < currentIndexes.length; k++)
                {
                    currentIndexes[k] = currentIndexes[k - 1] + 1;
                }
                return;
            }
        }
        // otherwise, we are all done:
        currentIndexes = null;
    }
1005284
function make_sector_list(sectors, dir_start, fat_addrs, ssz) {
	var sl = sectors.length, sector_list = ([]);
	var chkd = [], buf = [], buf_chain = [];
	var modulus = ssz - 1, i=0, j=0, k=0, jj=0;
	for(i=0; i < sl; ++i) {
		buf = ([]);
		k = (i + dir_start); if(k >= sl) k-=sl;
		if(chkd[k]) continue;
		buf_chain = [];
		for(j=k; j>=0;) {
			chkd[j] = true;
			buf[buf.length] = j;
			buf_chain.push(sectors[j]);
			var addr = fat_addrs[Math.floor(j*4/ssz)];
			jj = ((j*4) & modulus);
			if(ssz < 4 + jj) throw new Error("FAT boundary crossed: " + j + " 4 "+ssz);
			if(!sectors[addr]) break;
			j = __readInt32LE(sectors[addr], jj);
		}
		sector_list[k] = ({nodes: buf, data:__toBuffer([buf_chain])});
	}
	return sector_list;
}
1201972
def index_2d(seqs: List[List[Any]], target: Any) -> Tuple[int, int]:
    
    for i in range(len(seqs)):
        for j in range(len(seqs[i])):
            if seqs[i][j] == target:
                return i, j
    raise ValueError('Item not present.')
190961
public static <S> List<S> of(List<? extends S> left, List<? extends S> right) {
        List<S> list = new ArrayList<S>(left.size() + right.size());
        list.addAll(left);
        list.addAll(right);
        return list;
    }
572206
def lower
      position? ?
          siblings.where(klass.arel_table[klass.ordered_tree.columns.position].gteq(position)) :
          siblings
    end
561545
private Collection<State> updateStateListForChar(Iterable<State> states, int index) {
    Collection<State> result = new LinkedList<>();
    for (State state : states) {
      updateStateForChar(state, index, result);
    }
    return simplifyStates(result);
  }
1201810
def neighbors( open_list=[], closed_list=[] )
      i,j = free_cell      
      up = moved_matrix_with_parent(i, j, i-1, j, open_list, closed_list)
      down = moved_matrix_with_parent(i, j, i+1, j, open_list, closed_list)
      left = moved_matrix_with_parent(i, j, i, j-1, open_list, closed_list)
      right = moved_matrix_with_parent(i, j, i, j+1, open_list, closed_list)

      moved = []
      moved << up if !up.nil? 
      moved << down if !down.nil? 
      moved << left if !left.nil? 
      moved << right if !right.nil? 

      return moved
    end
331857
private int partitionItems(int left, int right, int pivot, double[] origin) {
		double pivotDistance = distance(origin, items[pivot]);
		listSwap(items, pivot, right - 1);
		listSwap(indexes, pivot, right - 1);
		int storeIndex = left;
		for (int i = left; i < right - 1; i++) {
			if (distance(origin, items[i]) <= pivotDistance) {
				listSwap(items, i, storeIndex);
				listSwap(indexes, i, storeIndex);
				storeIndex++;
			}
		}
		listSwap(items, storeIndex, right - 1);
		listSwap(indexes, storeIndex, right - 1);
		return storeIndex;
	}
1169345
private static int partition(SortedListView list,
            int left, int right) {
        int i = left - 1;
        int j = right;
        while (true) {
            while (less(list.getDouble(++i), list.getDouble(right)))      // find item on left to swap
            ;                               // a[right] acts as sentinel
            while (less(list.getDouble(right), list.getDouble(--j))) // find item on right to swap
            {
                if (j == left) {
                    break;           // don't go out-of-bounds
                }
            }
            if (i >= j) {
                break;                  // check if pointers cross
            }
            list.exhange(i, j);               // swap two elements into place
        }
        list.exhange(i, right);               // swap with partition element
        return i;
    }