25 #ifndef __NODE_VECTOR_H
26 #define __NODE_VECTOR_H
95 static const OverlayKey&
key(
const std::pair<NodeHandle, simtime_t>& nodes)
97 return nodes.first.getKey();
362 template <
class T,
class T_key,
class T_prox,
class T_address>
403 typedef typename std::vector<T>::iterator
iterator;
423 return (std::vector<T>::size() !=
maxSize ||
426 T_key::key(std::vector<T>::back())) <= 0 )) ||
429 T_prox::prox(std::vector<T>::back())) <= 0 )) ||
432 T_key::key(element)),
433 ProxKey(T_prox::prox(std::vector<T>::back()),
434 T_key::key(std::vector<T>::back()))) <= 0 )));
444 return(std::vector<T>::size() ==
maxSize);
454 return(std::vector<T>::size() == 0);
464 int add(
const T& element )
472 if ((std::vector<T>::size() != 0) &&
475 for (i = std::vector<T>::begin(), pos=0;
476 i != std::vector<T>::end(); i++, pos++) {
479 if (!T_key::key(element).isUnspecified()) {
480 if (T_key::key(element) == T_key::key(*i)) {
484 if (T_address::address(element) == T_address::address(*i)) {
496 if (compResult < 0) {
497 iterator temp_it = std::vector<T>::insert(i, element);
501 while ((tempPos <
sizeProx) && (temp_it != std::vector<T>::end())) {
511 (temp_it != std::vector<T>::end())) {
513 std::vector<T>::erase(temp_it);
524 ProxKey(T_prox::prox(*i), T_key::key(*i)));
525 if (compResult < 0) {
526 iterator temp_it = std::vector<T>::insert(i, element);
530 (temp_it != std::vector<T>::end())) {
536 (temp_it != std::vector<T>::end())) {
538 std::vector<T>::erase(temp_it);
550 if (compResult < 0) {
551 std::vector<T>::insert(i, element);
556 if (i == std::vector<T>::end()) {
557 pos = std::vector<T>::size();
558 this->push_back(element);
561 for (
iterator i = std::vector<T>::begin(); i != std::vector<T>::end();
563 std::cout <<
"should not happen" << std::endl;
565 if (T_key::key(element) == T_key::key(*i)) {
569 pos = std::vector<T>::size();
571 this->push_back(element);
576 std::vector<T>::resize(
maxSize);
591 i != std::vector<T>::end(); i++) {
592 if (T_key::key(*i) == key)
return true;
608 i != std::vector<T>::end(); i++) {
609 if (T_key::key(*i) == key)
return *i;
624 for (i = std::vector<T>::begin(); i != std::vector<T>::end(); i++)
625 if (T_key::key(*i) == key)
break;
636 if (std::vector<T>::size() > maxElements) {
637 std::vector<T>::erase(std::vector<T>::begin()+maxElements, std::vector<T>::end());
646 template <
class T,
class T_key,
class T_rtt,
class T_address>