-
Notifications
You must be signed in to change notification settings - Fork 53
Danmaku Groups
Danmaku Groups are a solution to the combination of two issues:
- Danmaku objects are often short lived, often living less than ~10 seconds at most. Thus the reference to them is useless after they are deleted.
- Danmaku objects that are similar often are manipulated in a similar way.
Danmaku Groups solves these issues by creating collection objects (like arrays, lists, sets, etc) for Danmaku that automatically remove Danmaku when they are deleted. This way Danmaku Groups are assured to always contain only active Danmaku objects or null values.
Danmaku Groups is implemented as a abstract class DanmakuGroup
. One can use either the built in subclasses or create their own.
The built in subclasses includes DanmakuGroup<T>
, DanmakuSet
, and DanmakuList
.
###DanmakuSet This is likely to be the most commonly used Danmaku Group. Due to being backed by a HashSet. It's Add, Remove, Contains, and Clear all run in amortized O(1) time, and thus is very efficient, and it also cannot contain more than one copy of the same Danmaku object. It can be iterated through just like any other collection, but the order in which specific Danmaku objects appear is not guaranteed to be the same as when they were added to the set.