find the average search depth. Include the null entries for cost.

@param history of hash table.
@rtype Number.
549168
function getDepth(history) {
    var total= history[0];
    for (var n=1; n < history.length; n++) {
        total = total + (n * n * history[n]);
    }
    var result = total / agents.length;
//    console.log("total=" + total+", result=" + result);
    return result;
}
1316097
public synchronized void setHistory(CollectHistory history) {
        history_ = Optional.of(history);
        history_.ifPresent(getApi()::setHistory);
        data_.initWithHistoricalData(history, getDecoratorLookBack());
    }
447280
function(historyinfo){
		this.allerase();
		
		this.initpos = this.position = historyinfo.current || 0;
		this.history = [];
		var datas = historyinfo.datas || [];
		for(var i=0,len=datas.length;i <len;i++){
			var opelist = new this.klass.OperationList();
			this.history.push(opelist);
			var array = datas[i];
			if(array.time!==void 0){
				opelist.time = array.time;
				array = array.ope;
			}
			for(var j=0,len2=array.length;j <len2;j++){
				var strs = array[j].split(/,/);
				var ope = null, List = this.operationlist;
				for(var k=0;k <List.length;k++){
					var ope1 = new List[k]();
					if(ope1.decode(strs)){ ope = ope1; break;}
				}
				if(!!ope){
					opelist.push(ope);
					this.lastope = ope;
				}
			}
		}
		
		this.checkexec();
		
		this.trialpos = historyinfo.trialpos || [];
		if(this.trialpos.length>0){
			this.resumeTrial();
			this.limitTrialUndo = true;
		}
	}
334945
private void handleGetMetricHistory(final int executorId, final HttpServletRequest req,
      final HashMap<String, Object> ret, final User user) throws IOException,
      ServletException {
    try {
      final Map<String, Object> result =
          this.execManagerAdapter.callExecutorStats(executorId,
              ConnectorParams.STATS_GET_METRICHISTORY, getAllParams(req));
      if (result.containsKey(ConnectorParams.RESPONSE_ERROR)) {
        ret.put(ConnectorParams.RESPONSE_ERROR,
            result.get(ConnectorParams.RESPONSE_ERROR).toString());
      } else {
        ret.put("data", result.get("data"));
      }
    } catch (final ExecutorManagerException ex) {
      logger.error(ex.getMessage(), ex);
      ret.put("error", "Failed to fetch metric history");
    }
  }
986642
def get_history(self):
        """"""
        self.load_history()
        return map(lambda x: (x, self.history[x]), self.ordered_history)
413367
def get_current_history_length(self):
        '''
        value = len(self.history)
        log(u"get_current_history_length:%d"%value)
        return value
1001134
private void depthFirstSearch(final Range<C> query, final Node node, final List<Range<C>> result, final Set<Node> visited) {
        if (node == null || visited.contains(node) || query.isEmpty()) {
            return;
        }
        if (node.left() != null && Ranges.isLessThan(query, node.center())) {
            depthFirstSearch(query, node.left(), result, visited);
        }
        else if (node.right() != null && Ranges.isGreaterThan(query, node.center())) {
            depthFirstSearch(query, node.right(), result, visited);
        }
        if (Ranges.isGreaterThan(query, node.center())) {
            for (Range<C> range : node.overlapByUpperEndpoint()) {
                if (Ranges.intersect(range, query)) {
                    result.add(range);
                }
                if (Ranges.isGreaterThan(query, range.upperEndpoint())) {
                    break;
                }
            }
        }
        else if (Ranges.isLessThan(query, node.center())) {
            for (Range<C> range : node.overlapByLowerEndpoint()) {
                if (Ranges.intersect(range, query)) {
                    result.add(range);
                }
                if (Ranges.isLessThan(query, range.lowerEndpoint())) {
                    break;
                }
            }
        }
        else {
            result.addAll(node.overlapByLowerEndpoint());
        }
        visited.add(node);
    }
912600
@Override
    public int compare(SnapshotHistory o1, SnapshotHistory o2) {
        return o1.history.compareTo(o2.history);
    }
407317
private HashtableEntry findEntry(EvictionTableEntry evt, int retrieveMode, long current, int tableid)
                    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {

        int hashcode = evt.hashcode;
        long previous = 0;

        long next = 0;
        int hash = 0;

        initReadBuffer(current);
        next = headerin.readLong();
        hash = headerin.readInt();

        while (current != 0) {
            //  System.out.println("current:"+current+" next:"+next);
            if (hash == hashcode) { // hash the same?
                // 		
                // Need to finish collision resolution and maybe return the object
                //   System.out.println("hashcode matched, hash:"+ hashcode); 
                HashtableEntry entry = readEntry2(current, next, hash, previous, retrieveMode, !CHECK_EXPIRED, tableid, null, evt); //493877
                if (entry != null) { // 493877 if entry is NOT null, the entry is found.
                    return entry;
                }
            }

            collisions++;
            //
            // Try for next object in bucket
            //
            previous = current;
            current = next;

            if (current != 0) { // optimize - don't read if we know we can't use it
                initReadBuffer(current);
                next = headerin.readLong();
                hash = headerin.readInt();
            }

        }

        //
        // If we fall through we did not find it
        //
        return null;
    }
847773
def AtMaximumDepth(self, search_depth):
    
    if self._location_segments is not None:
      if search_depth >= self._number_of_location_segments:
        return True

    return False
1238804
def depth_first(problem, graph_search=False, viewer=None):
    '''
    
    '''
    return _search(problem,
                   LifoList(),
                   graph_search=graph_search,
                   viewer=viewer)
1001719
private int findSlotBefore(SearchKey searchKey) {
		/*
		 * int slot = 0; while (slot < contents.getNumRecords() &&
		 * getKey(contents, slot).compareTo(searchKey) < 0) slot++; return slot
		 * - 1;
		 */
		// Optimization: Use binary search rather than sequential search
		int startSlot = 0, endSlot = currentPage.getNumRecords() - 1;
		int middleSlot = (startSlot + endSlot) / 2;

		if (endSlot >= 0) {
			while (middleSlot != startSlot) {
				if (getKey(currentPage, middleSlot, keyType.length())
						.compareTo(searchKey) < 0)
					startSlot = middleSlot;
				else
					endSlot = middleSlot;

				middleSlot = (startSlot + endSlot) / 2;
			}

			if (getKey(currentPage, endSlot, keyType.length()).compareTo(searchKey) < 0)
				return endSlot;
			else if (getKey(currentPage, startSlot, keyType.length())
					.compareTo(searchKey) < 0)
				return startSlot;
			else
				return startSlot - 1;
		} else
			return -1;
	}
1088323
public void addHistory(History history) {
        if (disableHistoryWrite) {
            return;
        }
        PreparedStatement statement = null;

        try (Connection sqlConnection = sqlService.getConnection()) {
            statement = sqlConnection.prepareStatement("INSERT INTO " + Constants.DB_TABLE_HISTORY +
                                                           "(" + Constants.GENERIC_PROFILE_ID + "," + Constants.GENERIC_CLIENT_UUID + "," +
                                                           Constants.HISTORY_CREATED_AT + "," + Constants.GENERIC_REQUEST_TYPE + "," +
                                                           Constants.HISTORY_REQUEST_URL + "," + Constants.HISTORY_REQUEST_PARAMS + "," +
                                                           Constants.HISTORY_REQUEST_POST_DATA + "," + Constants.HISTORY_REQUEST_HEADERS + "," +
                                                           Constants.HISTORY_RESPONSE_CODE + "," + Constants.HISTORY_RESPONSE_HEADERS + "," +
                                                           Constants.HISTORY_RESPONSE_CONTENT_TYPE + "," + Constants.HISTORY_RESPONSE_DATA + "," +
                                                           Constants.HISTORY_ORIGINAL_REQUEST_URL + "," + Constants.HISTORY_ORIGINAL_REQUEST_PARAMS + "," +
                                                           Constants.HISTORY_ORIGINAL_REQUEST_POST_DATA + "," + Constants.HISTORY_ORIGINAL_REQUEST_HEADERS + "," +
                                                           Constants.HISTORY_ORIGINAL_RESPONSE_CODE + "," + Constants.HISTORY_ORIGINAL_RESPONSE_HEADERS + "," +
                                                           Constants.HISTORY_ORIGINAL_RESPONSE_CONTENT_TYPE + "," + Constants.HISTORY_ORIGINAL_RESPONSE_DATA + "," +
                                                           Constants.HISTORY_MODIFIED + "," + Constants.HISTORY_REQUEST_SENT + "," +
                                                           Constants.HISTORY_REQUEST_BODY_DECODED + "," + Constants.HISTORY_RESPONSE_BODY_DECODED + "," +
                                                           Constants.HISTORY_EXTRA_INFO + "," + Constants.HISTORY_RAW_POST_DATA + ")" +
                                                           " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
            statement.setInt(1, history.getProfileId());
            statement.setString(2, history.getClientUUID());
            statement.setString(3, history.getCreatedAt());
            statement.setString(4, history.getRequestType());
            statement.setString(5, history.getRequestURL());
            statement.setString(6, history.getRequestParams());
            statement.setString(7, history.getRequestPostData());
            statement.setString(8, history.getRequestHeaders());
            statement.setString(9, history.getResponseCode());
            statement.setString(10, history.getResponseHeaders());
            statement.setString(11, history.getResponseContentType());
            statement.setString(12, history.getResponseData());
            statement.setString(13, history.getOriginalRequestURL());
            statement.setString(14, history.getOriginalRequestParams());
            statement.setString(15, history.getOriginalRequestPostData());
            statement.setString(16, history.getOriginalRequestHeaders());
            statement.setString(17, history.getOriginalResponseCode());
            statement.setString(18, history.getOriginalResponseHeaders());
            statement.setString(19, history.getOriginalResponseContentType());
            statement.setString(20, history.getOriginalResponseData());
            statement.setBoolean(21, history.isModified());
            statement.setBoolean(22, history.getRequestSent());
            statement.setBoolean(23, history.getRequestBodyDecoded());
            statement.setBoolean(24, history.getResponseBodyDecoded());
            statement.setString(25, history.getExtraInfoString());
            statement.setBytes(26, history.getRawPostData());
            statement.executeUpdate();

            // cull history
            cullHistory(history.getProfileId(), history.getClientUUID(), maxHistorySize);
        } catch (Exception e) {
            logger.info(e.getMessage());
        } finally {
            try {
                if (statement != null) {
                    statement.close();
                }
            } catch (Exception e) {
            }
        }
    }
691468
def prev_page(self):
        
        if self.history.position > self.lines and self.history.top:
            mid = min(len(self.history.top),
                      int(math.ceil(self.lines * self.history.ratio)))

            self.history.bottom.extendleft(
                self.buffer[y]
                for y in range(self.lines - 1, self.lines - mid - 1, -1))
            self.history = self.history \
                ._replace(position=self.history.position - mid)

            for y in range(self.lines - 1, mid - 1, -1):
                self.buffer[y] = self.buffer[y - mid]
            for y in range(mid - 1, -1, -1):
                self.buffer[y] = self.history.top.pop()

            self.dirty = set(range(self.lines))
879264
private HashtableEntry findEntry(Object key, int retrieveMode, boolean checkExpired)
                    throws IOException,
                    EOFException,
                    FileManagerException,
                    ClassNotFoundException,
                    HashtableOnDiskException {
        if (key == null) {
            return null;
        }

        int hashcode = key.hashCode();
        int index = header.getHtIndex(hashcode, header.currentTableId());
        long current = 0;
        HashtableEntry answer = null;

        if (header.rehashInProgress == 1) {

            if (debug)
                print("*");

            //
            // First search primary table.
            //
            if (htindex[index] != 0) {
                if (debug)
                    print("A");
                current = htindex[index];

                if (current == 0) {
                    throw new IllegalStateException("findEntry: ht pointer is null");
                }
                answer = findEntry(key, hashcode, retrieveMode, checkExpired, current, header.currentTableId());
                if (answer != null) {
                    return answer;
                }
            }

            //
            // Fell through, now search new table
            //
            index = header.getHtIndex(hashcode, header.alternateTableId());
            if (new_htindex[index] != 0) {
                if (debug)
                    print("B ");
                current = new_htindex[index];
                if (current == 0) {
                    throw new IllegalStateException("findEntry: ht pointer is null");
                }
                return findEntry(key, hashcode, retrieveMode, checkExpired, current, header.alternateTableId());
            }
            //
            // Fell through again, nothing here.
            //
            return null;
        } else {
            if (htindex[index] == 0) {
                return null;
            }
            int tableid = header.currentTableId();
            //current = header.calcOffset(index, tableid);
            current = htindex[index];
            if (current == 0) {
                throw new IllegalStateException("findEntry: ht pointer is null");
            }
            return findEntry(key, hashcode, retrieveMode, checkExpired, current, tableid);
        }
    }
1014954
@Override
  public UserTrades getTradeHistory(TradeHistoryParams params) throws IOException {

    CoinsuperTradeHistoryParams coinsuperTradeHistoryParams = (CoinsuperTradeHistoryParams) params;
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put("orderNoList", coinsuperTradeHistoryParams.getOrderNoList());

    CoinsuperResponse<List<OrderDetail>> orderDetails = orderDetails(parameters);
    // System.out.println(data);

    // CoinsuperUserTransaction[] coinsuperUserTransaction = null;

    return CoinsuperAdapters.adaptTradeHistory(orderDetails);
  }
808860
def depth_first_search (vis = DFSVisitor.new(self), &b)
      each_vertex do |u|
        unless vis.finished_vertex?(u)
          vis.handle_start_vertex(u)
          depth_first_visit(u, vis, &b)
        end
      end
    end