/*
GeneralSubtree ::= SEQUENCE {
base                    GeneralName,
minimum         [0]     BaseDistance DEFAULT 0,
maximum         [1]     BaseDistance OPTIONAL }
485710
public DERObject toASN1Object()
    {
        ASN1EncodableVector v = new ASN1EncodableVector();

        v.add(base);

        if (minimum != null)
        {
            v.add(new DERTaggedObject(false, 0, minimum));
        }

        if (maximum != null)
        {
            v.add(new DERTaggedObject(false, 1, maximum));
        }

        return new DERSequence(v);
    }
1240581
function Sequence (opts) {
    if (opts.actions) {
        return initWithActions(Object.getPrototypeOf(this).constructor, opts.actions)
    }

    if (!opts.one) {
        throw "Sequence argument one must be non-nil"
    }
    if (!opts.two) {
        throw "Sequence argument two must be non-nil"
    }
    this.actions = []

    var d = opts.one.duration + opts.two.duration

    Sequence.superclass.constructor.call(this, {duration: d})

    this.actions[0] = opts.one
    this.actions[1] = opts.two
}
483706
public void add(S sequence) {
        int start = currentEnd;
        this.sequence.add(sequence);
        suffix = new Suffix<>(currentEnd, currentEnd, this.sequence);
        activePoint.setPosition(root, null, 0);
        extendTree(start, this.sequence.getLength());
    }
743777
def bases(self):
        '''
        
        '''
        sequence = self.alignment.query_sequence
        assert self.offset_end <= len(sequence), \
            "End offset=%d > sequence length=%d. CIGAR=%s. SEQUENCE=%s" % (
                self.offset_end,
                len(sequence),
                self.alignment.cigarstring,
                sequence)
        return sequence[self.offset_start:self.offset_end]
243321
@SuppressWarnings("ConstantConditions")  // Complains that the code is too complex. Well duh!
  public static double scoreTree0(byte[] tree, double[] row, boolean computeLeafAssignment) {
    ByteBufferWrapper ab = new ByteBufferWrapper(tree);
    GenmodelBitSet bs = null;  // Lazily set on hitting first group test
    long bitsRight = 0;
    int level = 0;
    while (true) {
      int nodeType = ab.get1U();
      int colId = ab.get2();
      if (colId == 65535) return ab.get4f();
      int naSplitDir = ab.get1U();
      boolean naVsRest = naSplitDir == NsdNaVsRest;
      boolean leftward = naSplitDir == NsdNaLeft || naSplitDir == NsdLeft;
      int lmask = (nodeType & 51);
      int equal = (nodeType & 12);  // Can be one of 0, 8, 12
      assert equal != 4;  // no longer supported

      float splitVal = -1;
      if (!naVsRest) {
        // Extract value or group to split on
        if (equal == 0) {
          // Standard float-compare test (either < or ==)
          splitVal = ab.get4f();  // Get the float to compare
        } else {
          // Bitset test
          if (bs == null) bs = new GenmodelBitSet(0);
          if (equal == 8)
            bs.fill2(tree, ab);
          else
            bs.fill3_1(tree, ab);
        }
      }

      double d = row[colId];
      if (Double.isNaN(d)? !leftward : !naVsRest && (equal == 0? d >= splitVal : bs.contains0((int)d))) {
        // go RIGHT
        switch (lmask) {
          case 0:  ab.skip(ab.get1U());  break;
          case 1:  ab.skip(ab.get2());  break;
          case 2:  ab.skip(ab.get3());  break;
          case 3:  ab.skip(ab.get4());  break;
          case 48: ab.skip(4);  break;  // skip the prediction
          default:
            assert false : "illegal lmask value " + lmask + " in tree " + Arrays.toString(tree);
        }
        if (computeLeafAssignment && level < 64) bitsRight |= 1 << level;
        lmask = (nodeType & 0xC0) >> 2;  // Replace leftmask with the rightmask
      } else {
        // go LEFT
        if (lmask <= 3)
          ab.skip(lmask + 1);
      }

      level++;
      if ((lmask & 16) != 0) {
        if (computeLeafAssignment) {
          bitsRight |= 1 << level;  // mark the end of the tree
          return Double.longBitsToDouble(bitsRight);
        } else {
          return ab.get4f();
        }
      }
    }
  }
972203
function sequence ( map, components, results, missing, recursive, nest ) {
  components.forEach( component => {
    if ( results.indexOf( component ) !== -1 ) {
      return; // de-dup results
    }

    const deps = map.get( component );

    if ( ! deps ) {
      missing.push( component );
    } else if ( nest.indexOf( component ) > -1 ) {
      nest.push( component );
      recursive.push( nest.slice(0) );
      nest.pop( component );
    } else if ( deps.length ) {
      nest.push( component );
      sequence( map, deps, results, missing, recursive, nest ); // recurse
      nest.pop( component );
    }
    results.push( component );
  });
}
40758
def baseOrDerivedListString(self, lst, nodeByRefid):
        '''
        
        '''
        # lst should either be self.base_compounds or self.derived_compounds
        if not lst:
            return None

        bod_stream = StringIO()
        for prot, refid, string in lst:
            bod_stream.write("- ")

            # Include the prototype
            if prot:
                bod_stream.write("``{0}".format(prot))
                please_close = True
            else:
                please_close = False

            # Create the link, if possible
            # TODO: how to do intersphinx links here?
            if refid:
                # TODO: why are these links not working????????????????????????????????
                ###########flake8breaks :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/ :/
                # if please_close:
                #     bod_stream.write("`` ")  # close prototype
                # bod_stream.write("`{name} <{link}_>`_".format(
                #     # name=string.replace("<", "&gt;").replace(">", "&lt;"),
                #     name=string.replace("<", "").replace(">", ""),
                #     link=nodeByRefid[refid].link_name
                # ))
                if not please_close:
                    bod_stream.write("``")
                else:
                    bod_stream.write(" ")
                bod_stream.write("{string}`` (:ref:`{link}`)".format(
                    string=string,
                    link=nodeByRefid[refid].link_name
                ))
            else:
                if not please_close:
                    bod_stream.write("``")
                else:
                    bod_stream.write(" ")
                bod_stream.write("{0}``".format(string))
            bod_stream.write("\n")

        bod_value = bod_stream.getvalue()
        bod_stream.close()
        return bod_value
1053305
public static void ge_scalarmult_base(ge_p3 h, byte[] a) {
        byte[] e = new byte[64];
        byte carry;
        ge_p1p1 r = new ge_p1p1();
        ge_p2 s = new ge_p2();
        ge_precomp t = new ge_precomp();
        int i;

        for (i = 0; i < 32; ++i) {
            e[2 * i + 0] = (byte) ((a[i] >>> 0) & 15);
            e[2 * i + 1] = (byte) ((a[i] >>> 4) & 15);
        }
  /* each e[i] is between 0 and 15 */
  /* e[63] is between 0 and 7 */

        carry = 0;
        for (i = 0; i < 63; ++i) {
            e[i] += carry;
            carry = (byte) (e[i] + 8);
            carry >>= 4;
            e[i] -= carry << 4;
        }
        e[63] += carry;
  /* each e[i] is between -8 and 8 */

        ge_p3_0.ge_p3_0(h);
        for (i = 1; i < 64; i += 2) {
            select(t, i / 2, e[i]);
            ge_madd.ge_madd(r, h, t);
            ge_p1p1_to_p3.ge_p1p1_to_p3(h, r);
        }

        ge_p3_dbl.ge_p3_dbl(r, h);
        ge_p1p1_to_p2.ge_p1p1_to_p2(s, r);
        ge_p2_dbl.ge_p2_dbl(r, s);
        ge_p1p1_to_p2.ge_p1p1_to_p2(s, r);
        ge_p2_dbl.ge_p2_dbl(r, s);
        ge_p1p1_to_p2.ge_p1p1_to_p2(s, r);
        ge_p2_dbl.ge_p2_dbl(r, s);
        ge_p1p1_to_p3.ge_p1p1_to_p3(h, r);

        for (i = 0; i < 64; i += 2) {
            select(t, i / 2, e[i]);
            ge_madd.ge_madd(r, h, t);
            ge_p1p1_to_p3.ge_p1p1_to_p3(h, r);
        }
    }
482387
function flattenTree(root) {
  let newChildren = [];
  root.children.forEach(child => {
    const commonParent = getDeepMoreThenOneChild(child);
    if (commonParent.children.length === 0) {
      newChildren.push(commonParent);
    } else {
      newChildren = newChildren.concat(commonParent.children);
    }
  });
  root.children = newChildren;
}
52099
@Override
    public C.Sequence<T> prepend(C.Sequence<? extends T> seq) {
        if (seq instanceof C.List) {
            return prependList((C.List<T>) seq);
        }
        if (isLazy()) {
            return new CompositeSeq<T>(seq, this);
        }
        return unLazyPrepend(seq);
    }
1306419
private boolean addInstanceOfElement(HeaderElement root, HeaderElement elem) {
        // first add to the overall sequence list
        if (null == this.hdrSequence) {
            this.hdrSequence = elem;
            this.lastHdrInSequence = elem;
        } else {
            // find the end of the list and append this new element
            this.lastHdrInSequence.nextSequence = elem;
            elem.prevSequence = this.lastHdrInSequence;
            this.lastHdrInSequence = elem;
        }
        if (null == root) {
            return true;
        }
        HeaderElement prev = root;
        while (null != prev.nextInstance) {
            prev = prev.nextInstance;
        }
        prev.nextInstance = elem;
        return false;
    }
1042591
public static <T> Sequence<T> sort(final Sequence<T> sequence, final Comparator<T> comparator)
  {
    List<T> seqList = Sequences.toList(sequence, Lists.<T>newArrayList());
    Collections.sort(seqList, comparator);
    return BaseSequence.simple(seqList);
  }
1295567
public static <S extends Seq<S>> S concatenate(S... sequences) {
        if (sequences.length == 0)
            throw new IllegalArgumentException("Zero arguments");

        if (sequences.length == 1)
            return sequences[0];

        int size = 0;
        for (S s : sequences)
            size += s.size();

        SeqBuilder<S> builder = sequences[0].getBuilder().ensureCapacity(size);

        for (S s : sequences)
            builder.append(s);

        return builder.createAndDestroy();
    }
326198
@Override
    public Object mapSequence(Object sequence) {
        List<List<Float>> seq = (List<List<Float>>) sequence;
        List<Float> ret = new ArrayList<>();
        for (List<Float> step : seq)
            ret.add((Float) map(step));
        return ret;
    }
970510
private static final int binarySearchForRootPrimaryNode(
            int[] rootPrimaryIndexes, int length, long[] nodes, long p) {
        if(length == 0) { return ~0; }
        int start = 0;
        int limit = length;
        for (;;) {
            int i = (int)(((long)start + (long)limit) / 2);
            long node = nodes[rootPrimaryIndexes[i]];
            long nodePrimary = node >>> 32;  // weight32FromNode(node)
            if (p == nodePrimary) {
                return i;
            } else if (p < nodePrimary) {
                if (i == start) {
                    return ~start;  // insert s before i
                }
                limit = i;
            } else {
                if (i == start) {
                    return ~(start + 1);  // insert s after i
                }
                start = i;
            }
        }
    }
240090
def _build_inheritance_chain(cls, bases, *names, merge=False):
        """"""
        result = []
        for name in names:
            maps = []
            for base in bases:
                bmap = getattr(base, name, None)
                if bmap is not None:
                    assert isinstance(bmap, (dict, ChainMap))
                    if len(bmap):
                        if isinstance(bmap, ChainMap):
                            maps.extend(bmap.maps)
                        else:
                            maps.append(bmap)
            result.append(ChainMap({}, *maps))
        if merge:
            result = [dict(map) for map in result]
        if len(names) == 1:
            return result[0]
        return result
740608
function makeTree(left, ops, rights, minPrecedence = 0) {
  while (ops.length > 0 && precedence[ops[0]] >= minPrecedence) {
    let op = ops.shift();
    let right = rights.shift();
    while (ops.length > 0 && (precedence[ops[0]] > precedence[op] ||
        associativity[ops[0]] === 'R' && precedence[ops[0]] === precedence[op])) {
      right = makeTree(right, ops, rights, precedence[ops[0]]);
    }
    left = new BinaryExpression(left, op, right);
  }
  return left;
}