Right now DynamicBuffer solves the issue of storing multiple of the same component in an entity. However, performing operations on them usually takes O(n) time. A DynamicHashMap would allow constant time manipulation of component data. Understandably it would be hard to implement, but it would be very useful
Maybe you can write extensions for this by your self.
static class MyBufferExtension {
public static void Add(this DynamicBuffer<T> buffer, T Value) where T : struct, IBufferElementData, IHashable {
int hash = T.GetHashSomeHash();
// do quicksearch by hash
// do some insert
}
}
You can also use custom item container or what ever.
struct HashItem<T> : IBufferElementData where T : struct {
public int Hash;
public T Value;
}
static class MyBufferExtension {
public static void Add(this DynamicBuffer<HashItem<T>> buffer, T Value) where T : struct {
int hash = T.GetHashSomeHash();
// do quicksearch by hash
// do some insert
}
}
Anyway yes you are right. It would be nice to have something like that.
1 Like