<commit_before>library hetimatorrent.dht.kbucket;

import 'dart:core';
import 'kpeerinfo.dart';

class KBucket {
  int _k = 8;
  int get k => _k;

  List<KPeerInfo> peerInfos = null;
  KBucket(int kBucketSize) {
    this._k = kBucketSize;
    this.peerInfos = [];
  }

  add(KPeerInfo peerInfo) {
    if (peerInfos.contains(peerInfo) == true) {
      peerInfos.remove(peerInfo);
    }
    peerInfos.add(peerInfo);
    peerInfos.sort((KPeerInfo a, KPeerInfo b) {
      if (a.id == b.id) {
        return 0;
      } else if (a.id > b.id) {
        return 1;
      } else {
        return -1;
      }
    });
    if (peerInfos.length > k) {
      peerInfos.removeAt(0);
    }
  }

  int get length => peerInfos.length;
  KPeerInfo operator[](int idx) => peerInfos[idx];
  Iterator<KPeerInfo> get iterator => peerInfos.iterator;
}<commit_msg>mod kid interface<commit_after>library hetimatorrent.dht.kbucket;

import 'dart:core';
import 'kpeerinfo.dart';

class KBucket {
  int _k = 8;
  int get k => _k;
  List<KPeerInfo> peerInfos = null;

  KBucket(int kBucketSize) {
    this._k = kBucketSize;
    this.peerInfos = [];
  }

  add(KPeerInfo peerInfo) {
    if (peerInfos.contains(peerInfo) == true) {
      peerInfos.remove(peerInfo);
    }
    peerInfos.add(peerInfo);
    peerInfos.sort((KPeerInfo a, KPeerInfo b) {
      return (a.id == b.id ? 0 : (a.id > b.id ? 1 : -1));
    });
    if (peerInfos.length > k) {
      peerInfos.removeAt(0);
    }
  }

  int get length => peerInfos.length;
  KPeerInfo operator [](int idx) => peerInfos[idx];
  Iterator<KPeerInfo> get iterator => peerInfos.iterator;
}
{'fraction_non_alphanumeric': 0.14348097317529632, 'fraction_numerical': 0.006238303181534623, 'mean_word_length': 2.8190476190476192, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4478166', 'n_tokens_mistral': 623, 'n_tokens_neox': 611, 'n_words': 125}