Recreates the entries master list based on the groups hierarchy (order matters here,
        since the parser uses order to determine lineage).
438592
def _rebuild_entries(self):
        
        self.entries = []
        def collapse_entries(group):
            for entry in group.entries:
                self.entries.append(entry)
            for subgroup in group.children:
                collapse_entries(subgroup)
                
        collapse_entries(self.root)
717463
private void commitEntries() {
    raft.checkThread();

    // Sort the list of replicas, order by the last index that was replicated
    // to the replica. This will allow us to determine the median index
    // for all known replicated entries across all cluster members.
    List<RaftMemberContext> members = raft.getCluster().getActiveMemberStates((m1, m2) ->
        Long.compare(m2.getMatchIndex() != 0 ? m2.getMatchIndex() : 0L, m1.getMatchIndex() != 0 ? m1.getMatchIndex() : 0L));

    // If the active members list is empty (a configuration change occurred between an append request/response)
    // ensure all commit futures are completed and cleared.
    if (members.isEmpty()) {
      long commitIndex = raft.getLogWriter().getLastIndex();
      long previousCommitIndex = raft.setCommitIndex(commitIndex);
      if (commitIndex > previousCommitIndex) {
        log.trace("Committed entries up to {}", commitIndex);
        completeCommits(previousCommitIndex, commitIndex);
      }
      return;
    }

    // Calculate the current commit index as the median matchIndex.
    long commitIndex = members.get(getQuorumIndex()).getMatchIndex();

    // If the commit index has increased then update the commit index. Note that in order to ensure
    // the leader completeness property holds, we verify that the commit index is greater than or equal to
    // the index of the leader's no-op entry. Update the commit index and trigger commit futures.
    long previousCommitIndex = raft.getCommitIndex();
    if (commitIndex > 0 && commitIndex > previousCommitIndex && (leaderIndex > 0 && commitIndex >= leaderIndex)) {
      log.trace("Committed entries up to {}", commitIndex);
      raft.setCommitIndex(commitIndex);
      completeCommits(previousCommitIndex, commitIndex);
    }
  }
696369
private void categoryTreeToList(List<CmsCategoryBean> categoryList, List<CmsCategoryTreeEntry> entries) {

        if (entries == null) {
            return;
        }
        // skipping the root tree entry where the path property is empty
        for (CmsCategoryTreeEntry entry : entries) {
            CmsCategoryBean bean = new CmsCategoryBean(entry);
            categoryList.add(bean);
            categoryTreeToList(categoryList, entry.getChildren());
        }
    }
995673
public void completeGroup() {
		// Copy initial set to allow permutations to grow
		List<List<Integer>> gens = new ArrayList<List<Integer>>(permutations);
		// Keep HashSet version of permutations for fast lookup.
		Set<List<Integer>> known = new HashSet<List<Integer>>(permutations);
		//breadth-first search through the map of all members
		List<List<Integer>> currentLevel = new ArrayList<List<Integer>>(permutations);
		while( currentLevel.size() > 0) {
			List<List<Integer>> nextLevel = new ArrayList<List<Integer>>();
			for( List<Integer> p : currentLevel) {
				for(List<Integer> gen : gens) {
					List<Integer> y = combine(p,gen);
					if(!known.contains(y)) {
						nextLevel.add(y);
						//bypass addPermutation(y) for performance
						permutations.add(y);
						known.add(y);
					}
				}
			}
			currentLevel = nextLevel;
		}
	}
124995
def revisit(self, node, include_self=True):
        

        successors = self.successors(node) #, skip_reached_fixedpoint=True)

        if include_self:
            self._sorted_nodes.add(node)

        for succ in successors:
            self._sorted_nodes.add(succ)

        # reorder it
        self._sorted_nodes = OrderedSet(sorted(self._sorted_nodes, key=lambda n: self._node_to_index[n]))
779548
protected function resetSubGroups()
    {
        $reset = false;
        foreach ($this->parent->getGroups() as $group) {
            if ($reset) {
                $group->reset();
            }

            if ($group === $this) {
                $reset = true;
            }
        }
    }
1346661
@Override
	protected void rebuild() {
		mandatoryArcsList.clear();
		for (int i = 0; i < n; i++) {
			g.getNeighOf(i).clear();
			if (succ[i].isInstantiated()) {
				int j = succ[i].getValue();
				mandatoryArcsList.add(i * n + j); // todo check no need to have i < j
			}
		}
		for (int i = 0; i < n; i++) {
			IntVar v = succ[i];
			int ub = v.getUB();
			for (int j = v.getLB(); j <= ub; j = v.nextValue(j)) {
				g.addEdge(i, j);
			}
		}
	}
548108
private void buildGroupedRoot(Map<?,?> groupedItems, RecursiveTreeItem parent, int groupIndex) {
        boolean setRoot = false;
        if (parent == null) {
            parent = new RecursiveTreeItem<>(new RecursiveTreeObject(), RecursiveTreeObject::getChildren);
            setRoot = true;
        }

        for (Map.Entry<?, ?> entry : groupedItems.entrySet()) {
            Object key = entry.getKey();
            RecursiveTreeObject groupItem = new RecursiveTreeObject<>();
            groupItem.setGroupedValue(key);
            groupItem.setGroupedColumn(groupOrder.get(groupIndex));

            RecursiveTreeItem node = new RecursiveTreeItem<>(groupItem, RecursiveTreeObject::getChildren);
            // TODO: need to be removed once the selection issue is fixed
            node.expandedProperty().addListener((o, oldVal, newVal) -> {
                getSelectionModel().clearSelection();
            });

            parent.originalItems.add(node);
            parent.getChildren().add(node);

            Object children = entry.getValue();
            if (children instanceof List) {
                node.originalItems.addAll((List) children);
                node.getChildren().addAll((List) children);
            } else if (children instanceof Map) {
                buildGroupedRoot((Map) children, node, groupIndex + 1);
            }
        }

        // update ui
        if (setRoot) {
            final RecursiveTreeItem<S> newParent = parent;
            JFXUtilities.runInFX(() -> {
                ArrayList<TreeTableColumn<S, ?>> sortOrder = new ArrayList<>();
                sortOrder.addAll(getSortOrder());
                internalSetRoot = true;
                setRoot(newParent);
                internalSetRoot = false;
                getSortOrder().addAll(sortOrder);
                getSelectionModel().select(0);
            });
        }
    }
316920
def reorder_levels(self, order):
        
        order = [self._get_level_number(i) for i in order]
        if len(order) != self.nlevels:
            raise AssertionError('Length of order must be same as '
                                 'number of levels (%d), got %d' %
                                 (self.nlevels, len(order)))
        new_levels = [self.levels[i] for i in order]
        new_codes = [self.codes[i] for i in order]
        new_names = [self.names[i] for i in order]

        return MultiIndex(levels=new_levels, codes=new_codes,
                          names=new_names, verify_integrity=False)
148943
def ancestors(self):
    
    ret = []
    workunit = self
    while workunit is not None:
      ret.append(workunit)
      workunit = workunit.parent
    return ret
66276
public function recreateDefaults()
    {
        // Administrator group
        /** @var AdminUserGroup $group */
        $group = AdminUserGroupRepository::findOneEntityById(1);

        // If no any Admin group - create new empty group
        if (!$group || !$group->getUndeletable() || !$group->getCanSetPermissions() || !$group->getFullAccess()) {
            if ($group) {
                $group->is_super_admin = true;
                $group
                    ->setField('undeletable', 1)
                    ->setField('can_set_permissions', 1)
                    ->setField('structure_permissions', 1)
                    ->setFullAccess(1)
                    ->save();
            } else {

                // Delete all groups
                $group_collection = new AdminUserGroupRepository();
                $group_collection->deleteObjectCollection();

                // Drop auto-increment value
                $group_collection->alterTableResetAutoIncrement();

                // Create new Group for Admins
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 1,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Developers',
                    ]
                );
                $group->save();

                // Create new Group for Managers
                $group = new AdminUserGroup();
                $group->is_super_admin = true;
                $group->loadDataFromArray(
                    [
                        'undeletable'           => 0,
                        'can_set_permissions'   => 1,
                        'structure_permissions' => 1,
                        'full_access'           => 1,
                        'title'                 => 'Managers',
                        'default'               => 1,
                    ]
                );
                $group->save();

                echo '<br>Default User Group is created.<br>';
            }
        }

        unset($data);

        // Check we have any active Admin
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $have_any_user = $users_collection->hasAnyObjectInCollection();

        // Check we have admin as first User
        $users_collection = new AdminUserRepository();
        $users_collection->setWhereActive(1);
        $users_collection->setWhereId(1);
        $users_collection->setWhereGroupId(1);
        $users_collection->setWhereLogin('neTpyceB'); // Name of vendor repo owner
        $have_default_user = $users_collection->hasAnyObjectInCollection();

        // Recreate default User
        if (!$have_any_user || !$have_default_user) {
            //Remove all Users
            $users_collection = new AdminUserRepository;
            $users_collection->deleteObjectCollection();

            // Reset auto-increment
            $users_collection->alterTableResetAutoIncrement();

            // Create new default Developer
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 1, // Developer
                    'login'    => 'neTpyceB', // Name of vendor repo owner
                    'password' => $this->generateHash(Configuration::getInstance()->get('cms')['unique_key']), // Password is the same as unique key
                    'active'   => 1,
                ]
            );
            $user->save();

            // Create new default Manager
            $user = new AdminUser;
            $user->loadDataFromArray(
                [
                    'group_id' => 2, // Manager
                    'login'    => 'manager',
                    'password' => $this->generateHash(''), // Empty password
                    'active'   => 1,
                ]
            );
            $user->save();

            echo '<br>Default User "manager" and empty password is created.
			<br>
			Please log in and change password.
			<br>';
        }
    }
1073714
def ancestors(self):
        '''
        
        '''
        ancestors = []
        parent = self.parent
        while parent:
            ancestors.append(parent)
            parent = parent.parent
        return ancestors
862859
def recreate(years)
		list = []
		@plugin.__send__(:transaction, 'category') do |db|
			db.keys.each {|key|db.delete(key)}

			years.each do |y, ms|
				ms.each do |m|
					m = DiaryContainer::find_by_month(@conf, "#{y}#{m}")
					m.diaries.each do |ymd, diary|
						next if !diary.visible? or !diary.categorizable?
						categorized = categorize_diary(diary)
						categorized.keys.each do |c|
							cat = get(db, c) || {}
							set(db, c, cat.update(categorized[c]))
						end
						diary.each_section do |s|
							list |= s.categories unless s.categories.empty?
						end
					end
				end
			end
		end

		replace_categories(list)
	end
646661
def rearrange
      if self.parent_id
        self.parent_ids = parent.parent_ids + [self.parent_id]
      else
        self.parent_ids = []
      end

      self.depth = parent_ids.size

      rearrange_children! if self.parent_ids_changed?
    end
900938
function groupsFactory() {
  let list = []

  const getGroupsByRoot = function(root) {
    for (let i = 0; i < list.length; i++) {
      let groups = list[i]
      if (groups.rootEl === root) {
        return groups
      }
    }
    return null
  }

  return {
    add: function(root, group) {
      let groups = getGroupsByRoot(root)
      if (!groups) {
        groups = new Groups(root, [])
        list.push(groups)
      }
      if (group) {
        group._list = groups
        group.resolve()

        groups.add(group)
      }
    },
    groups: function() {
      return list.length === 1 ? list[0] : list
    }
  }
}
304241
def expand_heirarchy(levels)
      result = levels.clone
      
      levels.each do |name, level|
        # only need to expand on loggers since outputter already in list
        if  Log4r::Outputter[name].nil?
          logger = Lumber.find_or_create_logger(name)
          while logger
            logger_name = logger.fullname
            break if logger_name.nil?
            result[logger_name] ||= level
            logger.outputters.each do |o|
              result[o.name] ||= level
            end
            logger = logger.parent
          end
        end
      end
      
      return result
    end
485304
private SortedMap<Object, ResetableIterator> regroup(Object key,
                                                       Iterator arg1, Reporter reporter) throws IOException {
    this.numOfValues = 0;
    SortedMap<Object, ResetableIterator> retv = new TreeMap<Object, ResetableIterator>();
    TaggedMapOutput aRecord = null;
    while (arg1.hasNext()) {
      this.numOfValues += 1;
      if (this.numOfValues % 100 == 0) {
        reporter.setStatus("key: " + key.toString() + " numOfValues: "
                           + this.numOfValues);
      }
      if (this.numOfValues > this.maxNumOfValuesPerGroup) {
        continue;
      }
      aRecord = ((TaggedMapOutput) arg1.next()).clone(job);
      Text tag = aRecord.getTag();
      ResetableIterator data = retv.get(tag);
      if (data == null) {
        data = createResetableIterator();
        retv.put(tag, data);
      }
      data.add(aRecord);
    }
    if (this.numOfValues > this.largestNumOfValues) {
      this.largestNumOfValues = numOfValues;
      LOG.info("key: " + key.toString() + " this.largestNumOfValues: "
               + this.largestNumOfValues);
    }
    return retv;
  }