Visit ordered list items.  Starts the list with `node.start` and increments each following list item bullet by one:  2. foo 3. bar  In `incrementListMarker: false` mode, does not increment each marker and stays on `node.start`:  1. foo 1. bar
763868
function orderedItems(node) {
  var self = this
  var fn = self.visitors.listItem
  var increment = self.options.incrementListMarker
  var values = []
  var start = node.start
  var children = node.children
  var length = children.length
  var index = -1
  var bullet

  start = start == null ? 1 : start

  while (++index < length) {
    bullet = (increment ? start + index : start) + dot
    values[index] = fn.call(self, children[index], node, index, bullet)
  }

  return values.join(node.spread ? blank : lineFeed)
}
182046
function(start, end, direction) {
      var current = (start = startOfLine(start)), before = start && startOfLine(start.previousSibling);
      if (!isBR(end)) end = endOfLine(end, this.container);
      this.addDirtyNode(start);

      do {
        var next = endOfLine(current, this.container);
        if (current) this.highlight(before, next, true);
        this.indentLineAfter(current, direction);
        before = current;
        current = next;
      } while (current != end);
      select.setCursorPos(this.container, {node: start, offset: 0}, {node: end, offset: 0});
    }
445814
function() {
				if ( list ) {
					// First, we save the current length
					var start = list.length;
					(function add( args ) {
						jQuery.each( args, function( _, arg ) {
							var type = jQuery.type( arg );
							if ( type === "function" ) {
								if ( !options.unique || !self.has( arg ) ) {
									list.push( arg );
								}
							} else if ( arg && arg.length && type !== "string" ) {
								// Inspect recursively
								add( arg );
							}
						});
					})( arguments );
					// Do we need to add the callbacks to the
					// current firing batch?
					if ( firing ) {
						firingLength = list.length;
					// With memory, if we're not firing then
					// we should call right away
					} else if ( memory ) {
						firingStart = start;
						fire( memory );
					}
				}
				return this;
			}
1044514
def add_list_start_and_ends
      level = 0
      res = []
      type_stack = []

      @fragments.each do |fragment|
        # $stderr.puts "#{level} : #{fragment.class.name} : #{fragment.level}"
        new_level = fragment.level
        while (level < new_level)
          level += 1
          type = fragment.type
          res << ListStart.new(level, fragment.param, type) if type
          type_stack.push type
          # $stderr.puts "Start: #{level}"
        end

        while level > new_level
          type = type_stack.pop
          res << ListEnd.new(level, type) if type
          level -= 1
          # $stderr.puts "End: #{level}, #{type}"
        end

        res << fragment
        level = fragment.level
      end
      level.downto(1) do |i|
        type = type_stack.pop
        res << ListEnd.new(i, type) if type
      end

      @fragments = res
    end
296432
function processList(ul) {
	if ( ul.getAttribute( "data-xdh-mktree" ) == "handled" )
		return;
	
	if (!ul.childNodes || ul.childNodes.length==0) { return; }
	// Iterate LIs
	var childNodesLength = ul.childNodes.length;
	for (var itemi=0;itemi<childNodesLength;itemi++) {
		var item = ul.childNodes[itemi];
		if (item.nodeName == "LI") {
			// Iterate things in this LI
			var subLists = false;
			var itemChildNodesLength = item.childNodes.length;
			for (var sitemi=0;sitemi<itemChildNodesLength;sitemi++) {
				var sitem = item.childNodes[sitemi];
				if (sitem.nodeName=="UL") {
					subLists = true;
					processList(sitem);
				}
			}
			var s= document.createElement("SPAN");
			var t= '\u00A0'; // &nbsp;
			s.className = nodeLinkClass;
			if (subLists) {
				// This LI has UL's in it, so it's a +/- node
				if (item.className==null || item.className=="") {
					item.className = nodeClosedClass;
				}
				// If it's just text, make the text work as the link also
				if (item.firstChild.nodeName=="#text") {
					t = t+item.firstChild.nodeValue;
					item.removeChild(item.firstChild);
				}
				s.onclick = treeNodeOnclick;
			}
			else {
				// No sublists, so it's just a bullet node
				item.className = nodeBulletClass;
				s.onclick = retFalse;
			}
			s.appendChild(document.createTextNode(t));
			item.insertBefore(s,item.firstChild);
		}
	}
}
1293857
function(list) {

                if (Array.isArray(list)) {

                    this.a.push.apply(this.a, list);

                } else {

                    for (var __$0 = (list)[Symbol.iterator](), __$1; __$1 = __$0.next(), !__$1.done;)
                        { var item$0 = __$1.value; this.a.push(item$0); }
                }

                return this;
            }
1136677
function(){
	ll('Starting final in TermDataStage...');

	// We're done, so hide the progress bar again and show the
	// order selector.
	jQuery('#progress-widget').hide();
	jQuery("#order-selector").show();

	// We want this to be fully defined at the end of the accumulator.
	var data = {
    	    graph: seen_links,
    	    nodes: [],
    	    links: []
	};

	// Now we map out term information into the same format as the
	// example.
	us.each(term_accs, function(acc){
	    var node = {
		'id': acc,
		'name': term_info[acc]['name'],
		'source': term_info[acc]['source'],
		'index': term_info[acc]['index']
	    };
	    data.nodes.push(node);
	});

	// Next, we put our link information into the same format as
	// the example.
	var already_done_links = {};
	us.each(seen_links, function(sub_data, sub){
	    us.each(sub_data, function(link_count, obj){

		// Only add links that we haven't yet.
		var li1 = sub + '_' + obj;
		var li2 = obj + '_' + sub;
		if( typeof(already_done_links[li1]) === 'undefined' ){
		    
		    // Add it to our done list. Either way
		    // we'll catch it.
		    already_done_links[li1] = true;
		    already_done_links[li2] = true;
		    
		    // Push the new link data.
		    var link = {
			'source': term_info[sub]['index'],
			'target': term_info[obj]['index'],
			'value': link_count
		    };
		    data.links.push(link);
		}
	    });
	});

	ll(' Seen links: ' + bbop.dump(seen_links));
	ll(' Data: ' + bbop.dump(data));
	ll(' Max count: ' + max_count);
	// //ll(h + ', ' + v + ': ' + count);
	// ll('accumulate: ' + axis1 + ', ' + axis2 + ': ' + count);

	ll('Completed TermDataStage!');
	RenderStage(data, max_count);
	//PlotStage(data, max_count);
    }
429412
def push(self, item, priority=None):
        
        priority = item if priority is None else priority
        node = PriorityQueueNode(item, priority)
        for index, current in enumerate(self.priority_queue_list):
            if current.priority < node.priority:
                self.priority_queue_list.insert(index, node)
                return
        # when traversed complete queue
        self.priority_queue_list.append(node)
1315630
function (data){
    
        //create a new item object, place data in
        var node = { 
                data: data, 
                next: null,
                prev: null
            };
    
        //special case: no items in the list yet
        if (this._length == 0) {
            this._head = node;
            this._tail = node;
        } else {
        
            //attach to the tail node
            this._tail.next = node;
            node.prev = this._tail;
            this._tail = node;
        }        
        
        //don't forget to update the count
        this._length++;
    
    }
1091696
function joinNextLineToCursor( editor, cursor, nextCursor ) {
		editor.fire( 'saveSnapshot' );

		// Merge with previous block's content.
		nextCursor.enlarge( CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS );
		var frag = nextCursor.extractContents();

		cursor.trim( false, true );
		var bm = cursor.createBookmark();

		// Kill original bogus;
		var currentPath = new CKEDITOR.dom.elementPath( cursor.startContainer ),
				pathBlock = currentPath.block,
				currentBlock = currentPath.lastElement.getAscendant( 'li', 1 ) || pathBlock,
				nextPath = new CKEDITOR.dom.elementPath( nextCursor.startContainer ),
				nextLi = nextPath.contains( CKEDITOR.dtd.$listItem ),
				nextList = nextPath.contains( CKEDITOR.dtd.$list ),
				last;

		// Remove bogus node the current block/pseudo block.
		if ( pathBlock ) {
			var bogus = pathBlock.getBogus();
			bogus && bogus.remove();
		}
		else if ( nextList ) {
			last = nextList.getPrevious( nonEmpty );
			if ( last && blockBogus( last ) )
				last.remove();
		}

		// Kill the tail br in extracted.
		last = frag.getLast();
		if ( last && last.type == CKEDITOR.NODE_ELEMENT && last.is( 'br' ) )
			last.remove();

		// Insert fragment at the range position.
		var nextNode = cursor.startContainer.getChild( cursor.startOffset );
		if ( nextNode )
			frag.insertBefore( nextNode );
		else
			cursor.startContainer.append( frag );

		// Move the sub list nested in the next list item.
		if ( nextLi ) {
			var sublist = getSubList( nextLi );
			if ( sublist ) {
				// If next line is in the sub list of the current list item.
				if ( currentBlock.contains( nextLi ) ) {
					mergeChildren( sublist, nextLi.getParent(), nextLi );
					sublist.remove();
				}
				// Migrate the sub list to current list item.
				else
					currentBlock.append( sublist );
			}
		}

		var nextBlock, parent;
		// Remove any remaining zombies path blocks at the end after line merged.
		while ( nextCursor.checkStartOfBlock() && nextCursor.checkEndOfBlock() ) {
			nextPath = nextCursor.startPath();
			nextBlock = nextPath.block;

			// Abort when nothing to be removed (#10890).
			if ( !nextBlock )
				break;

			// Check if also to remove empty list.
			if ( nextBlock.is( 'li' ) ) {
				parent = nextBlock.getParent();
				if ( nextBlock.equals( parent.getLast( nonEmpty ) ) && nextBlock.equals( parent.getFirst( nonEmpty ) ) )
					nextBlock = parent;
			}

			nextCursor.moveToPosition( nextBlock, CKEDITOR.POSITION_BEFORE_START );
			nextBlock.remove();
		}

		// Check if need to further merge with the list resides after the merged block. (#9080)
		var walkerRng = nextCursor.clone(), editable = editor.editable();
		walkerRng.setEndAt( editable, CKEDITOR.POSITION_BEFORE_END );
		var walker = new CKEDITOR.dom.walker( walkerRng );
		walker.evaluator = function( node ) { return nonEmpty( node ) && !blockBogus( node ); };
		var next = walker.next();
		if ( next && next.type == CKEDITOR.NODE_ELEMENT && next.getName() in CKEDITOR.dtd.$list )
			mergeListSiblings( next );

		cursor.moveToBookmark( bm );

		// Make fresh selection.
		cursor.select();

		editor.fire( 'saveSnapshot' );
	}
891072
function( element )
				{
					var children = element.children, child,
							listItem,   // The current processing cke:li element.
							listItemAttrs,
							listItemIndent, // Indent level of current list item.
							lastIndent,
							lastListItem, // The previous one just been added to the list.
							list, // Current staging list and it's parent list if any.
							openedLists = [],
							previousListStyleType,
							previousListType;

					// Properties of the list item are to be resolved from the list bullet.
					var bullet,
						listType,
						listStyleType,
						itemNumeric;

					for ( var i = 0; i < children.length; i++ )
					{
						child = children[ i ];

						if ( 'cke:li' == child.name )
						{
							child.name = 'li';
							listItem = child;
							listItemAttrs = listItem.attributes;
							bullet = listItemAttrs[ 'cke:listsymbol' ];
							bullet = bullet && bullet.match( /^(?:[(]?)([^\s]+?)([.)]?)$/ );
							listType = listStyleType = itemNumeric = null;

							if ( listItemAttrs[ 'cke:ignored' ] )
							{
								children.splice( i--, 1 );
								continue;
							}


							// This's from a new list root.
							listItemAttrs[ 'cke:reset' ] && ( list = lastIndent = lastListItem = null );

							// List item indent level might come from a real list indentation or
							// been resolved from a pseudo list item's margin value, even get
							// no indentation at all.
							listItemIndent = Number( listItemAttrs[ 'cke:indent' ] );

							// We're moving out of the current list, cleaning up.
							if ( listItemIndent != lastIndent )
								previousListType = previousListStyleType = null;

							// List type and item style are already resolved.
							if ( !bullet )
							{
								listType = listItemAttrs[ 'cke:listtype' ] || 'ol';
								listStyleType = listItemAttrs[ 'cke:list-style-type' ];
							}
							else
							{
								// Probably share the same list style type with previous list item,
								// give it priority to avoid ambiguous between C(Alpha) and C.(Roman).
								if ( previousListType && listMarkerPatterns[ previousListType ] [ previousListStyleType ].test( bullet[ 1 ] ) )
								{
									listType = previousListType;
									listStyleType = previousListStyleType;
								}
								else
								{
									for ( var type in listMarkerPatterns )
									{
										for ( var style in listMarkerPatterns[ type ] )
										{
											if ( listMarkerPatterns[ type ][ style ].test( bullet[ 1 ] ) )
											{
												// Small numbering has higher priority, when dealing with ambiguous
												// between C(Alpha) and C.(Roman).
												if ( type == 'ol' && ( /alpha|roman/ ).test( style ) )
												{
													var num = /roman/.test( style ) ? fromRoman( bullet[ 1 ] ) : fromAlphabet( bullet[ 1 ] );
													if ( !itemNumeric || num < itemNumeric )
													{
														itemNumeric = num;
														listType = type;
														listStyleType = style;
													}
												}
												else
												{
													listType = type;
													listStyleType = style;
													break;
												}
											}
										}
									}
								}

								// Simply use decimal/disc for the rest forms of unrepresentable
								// numerals, e.g. Chinese..., but as long as there a second part
								// included, it has a bigger chance of being a order list ;)
								!listType && ( listType = bullet[ 2 ] ? 'ol' : 'ul' );
							}

							previousListType = listType;
							previousListStyleType = listStyleType || ( listType == 'ol' ? 'decimal' : 'disc' );
							if ( listStyleType && listStyleType != ( listType == 'ol' ? 'decimal' : 'disc' ) )
								listItem.addStyle( 'list-style-type', listStyleType );

							// Figure out start numbering.
							if ( listType == 'ol' && bullet )
							{
								switch ( listStyleType )
								{
									case 'decimal' :
										itemNumeric = Number( bullet[ 1 ] );
										break;
									case 'lower-roman':
									case 'upper-roman':
										itemNumeric = fromRoman( bullet[ 1 ] );
										break;
									case 'lower-alpha':
									case 'upper-alpha':
										itemNumeric = fromAlphabet( bullet[ 1 ] );
										break;
								}

								// Always create the numbering, swipe out unnecessary ones later.
								listItem.attributes.value = itemNumeric;
							}

							// Start the list construction.
							if ( !list )
							{
								openedLists.push( list = new CKEDITOR.htmlParser.element( listType ) );
								list.add( listItem );
								children[ i ] = list;
							}
							else
							{
								if ( listItemIndent > lastIndent )
								{
									openedLists.push( list = new CKEDITOR.htmlParser.element( listType ) );
									list.add( listItem );
									lastListItem.add( list );
								}
								else if ( listItemIndent < lastIndent )
								{
									// There might be a negative gap between two list levels. (#4944)
									var diff = lastIndent - listItemIndent,
											parent;
									while ( diff-- && ( parent = list.parent ) )
										list = parent.parent;

									list.add( listItem );
								}
								else
									list.add( listItem );

								children.splice( i--, 1 );
							}

							lastListItem = listItem;
							lastIndent = listItemIndent;
						}
						else if ( list )
							list = lastIndent = lastListItem = null;
					}

					for ( i = 0; i < openedLists.length; i++ )
						postProcessList( openedLists[ i ] );

					list = lastIndent = lastListItem = previousListId = previousListItemMargin = listBaseIndent = null;
				}
1329234
def increment_lineno(node, n=1):
    
    for node in zip((node,), walk(node)):
        if 'lineno' in node._attributes:
            node.lineno = getattr(node, 'lineno', 0) + n
213399
function getNextItemRange(model, anchor, getItemRanges) {
	// Find HTML node for next selection
	let node = nodeForPoint(model, anchor.start, 'next');
	let range;

	// We might need to narrow down node context to find best token match
	while (node && !range) {
		range = getNextRange(getItemRanges(node), anchor);
		node = node.firstChild || nextSibling(node);
	}

	return range;
}
1242248
function trackSelectedItem(element) {

  const items = element.items;
  const itemCount = items ? items.length : 0;

  const previousSelectedItem = element.selectedItem;
  if (!previousSelectedItem) {
    // No item was previously selected.
    if (element.selectionRequired) {
      // Select the first item by default.
      element.selectedIndex = 0;
    }
  } else if (itemCount === 0) {
    // We've lost the selection, and there's nothing left to select.
    element.selectedItem = null;
  } else {
    // Try to find the previously-selected item in the current set of items.
    const indexInCurrentItems = Array.prototype.indexOf.call(items, previousSelectedItem);
    const previousSelectedIndex = element.selectedIndex;
    if (indexInCurrentItems < 0) {
      // Previously-selected item was removed from the items.
      // Select the item at the same index (if it exists) or as close as possible.
      const newSelectedIndex = Math.min(previousSelectedIndex, itemCount - 1);
      // Select by item, since index may be the same, and we want to raise the
      // selected-item-changed event.
      element.selectedItem = items[newSelectedIndex];
    } else if (indexInCurrentItems !== previousSelectedIndex) {
      // Previously-selected item still there, but changed position.
      element.selectedIndex = indexInCurrentItems;
    }
  }
}
48079
def node_is_on_list(self, node):
        
        next = self.node_next(node)
        if next == node or next is None:
            assert(self.node_prev(node) is next)
            return False

        return True
234540
def _handle_list(self):
        """"""
        self._handle_list_marker()
        while self._read(1) in ("#", "*", ";", ":"):
            self._head += 1
            self._handle_list_marker()
1160522
public static boolean startsWith( List<?> list, List<?> prefix )
  {
    if( list.size() < prefix.size() )
    {
      return false;
    }
    Iterator<?> listIter = list.iterator();
    for( Object prefixElement : prefix )
    {
      boolean b = listIter.hasNext();
      assert b :
        "list claims to have at least as many elements as prefix, but its iterator is exhausted first";
      if( !GosuObjectUtil.equals( prefixElement, listIter.next() ) )
      {
        return false;
      }
    }
    return true;
  }