ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
302 stars 73 forks source link

C# build in type should be used instead of RBTree #37

Closed DevDrake closed 2 years ago

DevDrake commented 5 years ago

C# currently contains RBTree implementations such as SortedDictionary. For the sake of performance and maintainability build in type should be used.

Sonic-The-Hedgehog-LNK1123 commented 3 years ago

While build-in types should be used when possible, The SortedDictionary type you mentioned is unusable in this case since the Red-black tree node color that needs to be written to the compound files' directory entries isn't exposed by that type's API.

The reason OpenMCDF contains a Red-black tree implementation is because the compound file specification requires one. Because of those requirements, even if a datatype uses a Red-black tree internally doesn't mean it's usable, in this case the tree's node color needs to be accessible from the outside.

Edit: Also see this Stack Overflow answer.

ironfede commented 2 years ago

Thank you @Sonic-The-Hedgehog-LNK1123 for the clarification. I've used a custom implementation exactly for the aformentioned reason.