# uniquelyOccurring()

> Emit only those elements that occur in the input stream a single time.

---

Site [llms.txt](/gatherers4j/llms.txt)

---

### Implementation Notes

The implementation does not emit anything until the full input stream has been exhausted, so it is not suitable for infinite streams. 
Encounter order of uniquely occurring elements is preserved. 

Note that `uniquelyOccurring()` is semantically different from the JDK's [`Stream::distinct()`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/stream/Stream.html#distinct())or 
Gatherer4j's [`distinctBy()`](/gatherers4j/gatherers/filtering-and-selection/distinctby/)because only elements that are already distinct are emitted, rather than emitting all elements only once.

**Signature**

`uniquelyOccurring()`

### Examples

#### Limit stream to elements that occur a single time

```java
Stream
    .of("A", "B", "C", "A")
    .gather(Gatherers4j.uniquelyOccurring())
    .toList();

// ["B", "C"]
```
