/*
Before adding a new entry to the array of pending jobs, this will make sure there is enough room for it.
490138
private void ensurePendingCapacity() {
        if (this.pendingProcessings == null) {
            this.pendingProcessings = new IEngineProcessable[5];
            this.pendingProcessingsSize = 0;
        }
        if (this.pendingProcessingsSize == this.pendingProcessings.length) {
            this.pendingProcessings = Arrays.copyOf(this.pendingProcessings, this.pendingProcessings.length + 5);
        }
    }
507878
private void ensureCapacity() {
		if (size < selectionKeys.length) {
			return;
		}
		SelectionKey[] newArray = new SelectionKey[selectionKeys.length * 2];
		System.arraycopy(selectionKeys, 0, newArray, 0, size);
		selectionKeys = newArray;
	}
710547
@Override
  protected void preInsert(MkMaxEntry entry) {
    KNNHeap knns_o = DBIDUtil.newHeap(getKmax());
    preInsert(entry, getRootEntry(), knns_o);
  }
1024461
def pending_tasks(self, res):
        ""
        jobs, lock = self._jobs
        with lock:
            return jobs[res].copy()
888351
public void setEntries(List<FatDirectoryEntry> newEntries) {
        if (newEntries.size() > capacity)
            throw new IllegalArgumentException("too many entries");
        
        this.entries.clear();
        this.entries.addAll(newEntries);
    }
547566
def addPendingResult( self, ps, jobid ):
        """"""
        k = self._parametersAsIndex(ps)

        # retrieve or create the result list
        if k in self._results.keys():
            rs = self._results[k]
        else:
            rs = []
            self._results[k] = rs

        # append the pending result's jobid
        rs.insert(0, jobid)

        # map job id to parameters to which it refers
        self._pending[jobid] = k
1308789
function addWait(manager) {
            if (!waiting[manager.id]) {
                waiting[manager.id] = manager;
                waitAry.push(manager);
                context.waitCount += 1;
            }
        }
208796
private void addNewJobs(Set<BambooJob> jobs, List<BambooJob> existingJobs, BambooCollector collector) {
        long start = System.currentTimeMillis();
        int count = 0;

        List<BambooJob> newJobs = new ArrayList<>();
        for (BambooJob job : jobs) {
            BambooJob existing = null;
            if (!CollectionUtils.isEmpty(existingJobs) && (existingJobs.contains(job))) {
                existing = existingJobs.get(existingJobs.indexOf(job));
            }

            String niceName = getNiceName(job, collector);
            if (existing == null) {
                job.setCollectorId(collector.getId());
                job.setEnabled(false); // Do not enable for collection. Will be enabled when added to dashboard
                job.setDescription(job.getJobName());
                job.setLastUpdated(System.currentTimeMillis());
                if (StringUtils.isNotEmpty(niceName)) {
                    job.setNiceName(niceName);
                }
                newJobs.add(job);
                count++;
            } else if (StringUtils.isEmpty(existing.getNiceName()) && StringUtils.isNotEmpty(niceName)) {
                existing.setNiceName(niceName);
                bambooJobRepository.save(existing);
            }
        }
        //save all in one shot
        if (!CollectionUtils.isEmpty(newJobs)) {
            bambooJobRepository.save(newJobs);
        }
        log("New jobs", start, count);
    }
1269377
function addJobs(quantity) {
  const startId = jobs.length;
  for (let i = 0; i < quantity; i++) {
    const id = startId + i;
    jobs.push({
      id: id,
      name: 'Item name ' + id,
      type1: 'A',
      type2: 'B',
      active: i % 2 === 0 ? 'Y' : 'N',
      datetime: '200' + i + '-12-28T14:57:00'
    });
  }
}
1229037
function () {
                    //Check if any input was added dynamically
                    if (job.input.length > 0) {
                        job.is_complete = false;
                        return false;
                    }

                    //Wait for workers or instances that are still working
                    return worker_count > 0 ? areWorkersComplete() : job.instances <= 0;
                }
1079134
function() {
        for( var i = 0; i < this.jobQueue.length; i++ ) {
            var job = this.jobQueue[i];
            if ( typeof job.abort === "function" ) {
                job.abort();
            }
        }

        this.jobQueue = [];
    }
487098
public function checkQueue()
    {
        if ($this->backlog !== null) {
            while (!$this->backlog->isEmpty()) {
                if ($this->maxConcurrency !== -1 && ($this->jobsNum - $this->resultsNum > $this->maxConcurrency)) {
                    return;
                }
                list($name, $cb) = $this->backlog->shift();
                $this->addJob($name, $cb);
            }
        }
        if ($this->more !== null) {
            $this->more();
        }
    }
1206323
public final void addEntries(Entry<?>... entries) {
        if (entries != null) {
            for (Entry<?> entry : entries) {
                entry.setCalendar(this);
            }
        }
    }
461927
private void addInternalJobListener(JobListener jobListener) {

    if (jobListener.getName() == null || jobListener.getName().length() == 0) {
      throw new IllegalArgumentException("JobListener name cannot be empty.");
    }

    synchronized (internalJobListeners) {
      internalJobListeners.put(jobListener.getName(), jobListener);
    }
  }
820913
private <I> void addConsideringOrder(Map<String, I> map, I newEntry) {
    for(Map.Entry<String, I> entry : map.entrySet()) {
      if(entry.getValue() instanceof MustBeAfter<?>) {
        final Class<? extends ClassLoaderPreMortemCleanUp>[] existingMustBeAfter = 
            ((MustBeAfter<ClassLoaderPreMortemCleanUp>)entry.getValue()).mustBeBeforeMe();
        for(Class<? extends ClassLoaderPreMortemCleanUp> clazz : existingMustBeAfter) {
          if(clazz.isAssignableFrom(newEntry.getClass())) { // Entry needs to be after new entry
            // TODO Resolve order automatically #51
            throw new IllegalStateException(clazz.getName() + " must be added after " + newEntry.getClass());
          }
        }
      }
    }
    
    map.put(newEntry.getClass().getName(), newEntry);
  }
160847
synchronized public String addJob(Job aJob) {
    String id = this.getNextJobID();
    aJob.setJobID(id);
    aJob.setState(Job.WAITING);
    this.addToQueue(aJob);
    return id;	
  }
797912
@Override
    @SuppressWarnings("unchecked")
    protected void ensureCapacity(int capacity) {
        checkCapacity(capacity);
        K[] newArray = (K[]) new Object[capacity + 1];
        System.arraycopy(array, 1, newArray, 1, size);
        array = newArray;
    }