org.klomp.snark

## Class PeerCoordinatorSet

- java.lang.Object
- - org.klomp.snark.PeerCoordinatorSet

- All Implemented Interfaces:
    Iterable<PeerCoordinator>

      class PeerCoordinatorSet
      extends Object
      implements Iterable<PeerCoordinator>

  Thread-safe collection for managing PeerCoordinator instances across multiple torrents.

  This class provides a centralized registry for PeerCoordinator objects, enabling the multi-torrent functionality in I2PSnark. It is primarily used by:

  - PeerAcceptor - to route incoming connections to the correct coordinator
  - Snark instances - to register and unregister themselves
  - DHT and tracker systems - to find the appropriate coordinator for a torrent

  The set maps torrent info hashes to their corresponding PeerCoordinator instances, allowing efficient lookup by torrent identifier. All operations are thread-safe through ConcurrentHashMap.

  Each PeerCoordinator is automatically added when a torrent starts and removed when the torrent stops, ensuring the set always reflects currently active torrents.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PeerCoordinatorSet()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(PeerCoordinator coordinator)`
    `PeerCoordinator` | `get(byte[] infoHash)`
    `Iterator<PeerCoordinator>` | `iterator()`
    `void` | `remove(PeerCoordinator coordinator)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, spliterator`

- - ### Constructor Detail

    - #### PeerCoordinatorSet

          public PeerCoordinatorSet()

  - ### Method Detail

    - #### add

          public void add(PeerCoordinator coordinator)

    - #### get

          public PeerCoordinator get(byte[] infoHash)

    - #### iterator

          public Iterator<PeerCoordinator> iterator()

      Specified by:
        `iterator` in interface `Iterable<PeerCoordinator>`

    - #### remove

          public void remove(PeerCoordinator coordinator)