If this is only to de-duplicate the results of polling Teamcity's builds list, some sort of bounded de-duplicated queue might be sufficient.

Alternatively, can you just rely on the builds being ordered (by id or timestamp, for example), and record the maximum seen value?