Traverse all target elements and address presentational corrections if any two of them are adjacent to each other.
3687
function( context, target ) {
    var $$target = $.qsa( target || 'u, ins', context )
    var i = $$target.length

    traverse: while ( i-- ) {
      var $this = $$target[ i ]
      var $prev = null

      // Ignore all `<wbr>` and comments in between,
      // and add class `.adjacent` once two targets
      // are next to each other.
      ignore: do {
        $prev = ( $prev || $this ).previousSibling

        if ( !$prev ) {
          continue traverse
        } else if ( $$target[ i-1 ] === $prev ) {
          $this.classList.add( 'adjacent' )
        }
      } while ( $.isIgnorable( $prev ))
    }
  }
492671
function indexOfContainingItem(element, target) {
  const items = element.items;
  const itemCount = items ? items.length : 0;
  for (let i = 0; i < itemCount; i++) {
    let item = items[i];
    if (item === target || item.contains(target)) {
      return i;
    }
  }
  return -1;
}
424644
@SuppressWarnings("unchecked")
   protected Element findAndReplaceProperties(Counter counter, Element parent, String name, Map props)
   {
      boolean shouldExist = (props != null) && !props.isEmpty();
      Element element = updateElement(counter, parent, name, shouldExist);
      if (shouldExist)
      {
         Iterator it = props.keySet().iterator();
         Counter innerCounter = new Counter(counter.getDepth() + 1);
         while (it.hasNext())
         {
            String key = (String) it.next();
            findAndReplaceSimpleElement(innerCounter, element, key, (String) props.get(key), null);
         }

         List<String> lst = new ArrayList<String>(props.keySet());
         it = element.getChildren().iterator();
         while (it.hasNext())
         {
            Element elem = (Element) it.next();
            String key = elem.getName();
            if (!lst.contains(key))
            {
               it.remove();
            }
         }
      }
      return element;
   }
498874
private void checkTargets() {

        // checking current target first
        if ((m_currentTarget != null) && m_currentTarget.checkPosition(m_clientX, m_clientY, m_orientation)) {
            // in case of nested targets, check the children of the current target
            if ((m_currentTarget instanceof I_CmsNestedDropTarget)
                && ((I_CmsNestedDropTarget)m_currentTarget).hasDnDChildren()) {
                for (I_CmsDropTarget target : ((I_CmsNestedDropTarget)m_currentTarget).getDnDChildren()) {
                    if ((target != m_currentTarget) && target.checkPosition(m_clientX, m_clientY, m_orientation)) {
                        // notifying controller, if false is returned, placeholder will not be positioned inside target
                        if (m_controller.onTargetEnter(m_draggable, target, this)) {
                            target.insertPlaceholder(m_placeholder, m_clientX, m_clientY, m_orientation);
                            m_currentTarget = target;
                            m_controller.onPositionedPlaceholder(m_draggable, m_currentTarget, this);
                            return;
                        }
                    }
                }
            }
            if (m_currentTarget.getPlaceholderIndex() < 0) {
                m_currentTarget.insertPlaceholder(m_placeholder, m_clientX, m_clientY, m_orientation);
            } else {
                m_currentTarget.repositionPlaceholder(m_clientX, m_clientY, m_orientation);
            }

            m_controller.onPositionedPlaceholder(m_draggable, m_currentTarget, this);
        } else {
            // leaving the current target
            if (m_currentTarget != null) {
                m_controller.onTargetLeave(m_draggable, m_currentTarget, this);
            }
            for (I_CmsDropTarget target : m_targets) {
                if ((target != m_currentTarget) && target.checkPosition(m_clientX, m_clientY, m_orientation)) {
                    // notifying controller, if false is returned, placeholder will not be positioned inside target
                    if (m_controller.onTargetEnter(m_draggable, target, this)) {
                        target.insertPlaceholder(m_placeholder, m_clientX, m_clientY, m_orientation);
                        m_currentTarget = target;
                        m_controller.onPositionedPlaceholder(m_draggable, m_currentTarget, this);
                        return;
                    }
                }
            }
            // mouse position is not over any registered target
            m_currentTarget = null;
        }
    }
959241
def offset_overlays(self, text, run_matchers=None, **kw):
        

        self._maybe_run_matchers(text, run_matchers)
        for i in self._list_match.offset_overlays(text, **kw):
            yield i
732269
function updatePossibleNavigations(element) {
  let canSelectNext;
  let canSelectPrevious;
  const items = element.items;
  if (items == null || items.length === 0) {
    // No items to select.
    canSelectNext = false;
    canSelectPrevious = false;
  } if (element.selectionWraps) {
    // Since there are items, can always go next/previous.
    canSelectNext = true;
    canSelectPrevious = true;
  } else {
    const index = element.selectedIndex;
    if (index < 0 && items.length > 0) {
      // Special case. If there are items but no selection, declare that it's
      // always possible to go next/previous to create a selection.
      canSelectNext = true;
      canSelectPrevious = true;
    } else {
      // Normal case: we have an index in a list that has items.
      canSelectPrevious = (index > 0);
      canSelectNext = (index < items.length - 1);
    }
  }
  if (element.canSelectNext !== canSelectNext) {
    element.canSelectNext = canSelectNext;
  }
  if (element.canSelectPrevious !== canSelectPrevious) {
    element.canSelectPrevious = canSelectPrevious;
  }
}
322007
function() {
		// "Let target be the body element of the context object."
		var target = document.body;

		// "If target is null, let target be the context object's
		// documentElement."
		if (!target) {
			target = document.documentElement;
		}

		// "If target is null, call getSelection() on the context object, and
		// call removeAllRanges() on the result."
		if (!target) {
			getSelection().removeAllRanges();

		// "Otherwise, call getSelection() on the context object, and call
		// selectAllChildren(target) on the result."
		} else {
			getSelection().selectAllChildren(target);
		}
	}
304555
function(ast, offset) {
			var found = null;
			 CssVisitor.visit(ast, {
	            visitNode: function(node) {
					if(node.range[0] <= offset) {
						if (node.range[1] === -1 || node.range[1] >= offset) {
							found = node;
						} else {
							return Visitor.SKIP;
						}
					} else {
					    return Visitor.BREAK;
					}      
	            },
	            endVisitNode: function(node) {
	            }
	        });
	        return found;
		}
3067
private void sweep() {
        for (Node p = head, s, n; p != null && (s = p.next) != null; ) {
            if (!s.isMatched())
                // Unmatched nodes are never self-linked
                p = s;
            else if ((n = s.next) == null) // trailing node is pinned
                break;
            else if (UNLINKED == n)    // stale
                // No need to also check for p == s, since that implies s == n
                p = head;
            else
                p.casNext(s, n);
        }
    }
183888
def iflatten(seq, isSeq=isSeq):
    """
    for elt in seq:
        if isSeq(elt):
            for x in iflatten(elt, isSeq):
                yield x
        else:
            yield elt
538832
def _subsequent_step_to_match(match_step):
    """"""
    if not isinstance(match_step.root_block, (Traverse, Recurse)):
        raise AssertionError(u'Expected Traverse root block, received: '
                             u'{} {}'.format(match_step.root_block, match_step))

    is_recursing = isinstance(match_step.root_block, Recurse)

    match_step.root_block.validate()

    traversal_command = u'.%s(\'%s\')' % (match_step.root_block.direction,
                                          match_step.root_block.edge_name)

    parts = []
    if match_step.coerce_type_block:
        coerce_type_set = match_step.coerce_type_block.target_class
        if len(coerce_type_set) != 1:
            raise AssertionError(u'Found MATCH type coercion block with more than one target class:'
                                 u' {} {}'.format(coerce_type_set, match_step))
        coerce_type_target = list(coerce_type_set)[0]
        parts.append(u'class: %s' % (coerce_type_target,))

    if is_recursing:
        # In MATCH, "$depth < 1" means "include the source vertex and its immediate neighbors."
        # Yes, the "<" is intentional -- it's not supposed to be a "<=".
        parts.append(u'while: ($depth < %d)' % (match_step.root_block.depth,))

    if match_step.where_block:
        match_step.where_block.validate()
        parts.append(u'where: (%s)' % (match_step.where_block.predicate.to_match(),))

    if not is_recursing and match_step.root_block.optional:
        parts.append(u'optional: true')

    if match_step.as_block:
        match_step.as_block.validate()
        parts.append(u'as: %s' % (_get_vertex_location_name(match_step.as_block.location),))

    return u'%s {{ %s }}' % (traversal_command, u', '.join(parts))
1144551
function( containerNode, preceding, following )
    {
        if( window.getSelection )
        {
            var sel = window.getSelection();
            if( sel.modify )
            {
                for( var i=0; i < preceding; ++i )
                    sel.modify('extend', 'backward', 'character');
                for( var i=0; i < following; ++i )
                    sel.modify('extend', 'forward', 'character');
            }
            else
            {
                // not so easy if the steps would cover multiple nodes ...
                var range = sel.getRangeAt(0);
                range.setStart( range.startContainer, range.startOffset - preceding );
                range.setEnd( range.endContainer, range.endOffset + following );
                sel.removeAllRanges();
                sel.addRange(range);
            }
        }
        else if( document.selection )
        {
            var sel = document.selection;
            if( sel.type != 'Control' )
            {
                var range = sel.createRange();
                range.collapse(true);
                range.moveStart('character', -preceding);
                range.moveEnd('character', following);
                range.select();
            }
        }
    }
1308402
def adjacent(self, node_a, node_b):
        """"""
        neighbors = self.neighbors(node_a)
        return node_b in neighbors
647228
def adjacent(self,rng2):
    
    if self.chr != rng2.chr: return False
    if self.direction != rng2.direction and use_direction: return False
    if self.end == rng2.start-1:  return True
    if self.start-1 == rng2.end: return True
    return False
1048025
function it_provides_useful_information_about_iterations()
    {
        $this->next('one');
        $this->getIndex()->shouldBe(0);
        $this->getKey()->shouldBe('one');
        $this->isFirst()->shouldBe(true);
        $this->isLast()->shouldBe(false);

        $this->next('two');
        $this->getIndex()->shouldBe(1);
        $this->getKey()->shouldBe('two');
        $this->isFirst()->shouldBe(false);
        $this->isLast()->shouldBe(false);

        $this->next('three');
        $this->getIndex()->shouldBe(2);
        $this->getKey()->shouldBe('three');
        $this->isFirst()->shouldBe(false);
        $this->isLast()->shouldBe(true);
    }
1228748
def find_clashes(all_items):
    """"""
    clashes = {}
    seen_venue_slots = {}
    for item in all_items:
        for slot in item.slots.all():
            pos = (item.venue, slot)
            if pos in seen_venue_slots:
                if seen_venue_slots[pos] not in clashes:
                    clashes[pos] = [seen_venue_slots[pos]]
                clashes[pos].append(item)
            else:
                seen_venue_slots[pos] = item
    # We return a list, to match other validators
    return clashes.items()
522319
def overlapping(self, other):
        """"""
        return (
            other.start in self.ref_range) or (
            self.start in other.ref_range)