Replies: 2 comments 1 reply
-
|
By the way, I think it would be better to separate different classes into different files, especially when these classes are large. When trying to read the file |
Beta Was this translation helpful? Give feedback.
-
@ttzytt I totally agree with your point of view. Overloading the operators for |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Found some places to improve when using the package to implement the animation of a simple binary search algorithm:
For every comparison between
MArrayPointer, you have to callfetch_index()to get the position where the array is pointing. I think it will be better to overload comparators in MArrayPointer so that the implementation will be easier.The same works for other operators like add and subtract: the addition or subtraction between
MArrayPointeran integer or anotherMArrayPointershould give the addition and subtraction between the integer and the index that the pointer is pointing to in aMArray. That way, the operation of pointers will be much easier, and code like the following will be simplified:r.shift_to_elem(mid.fetch_index() - 1, play_anim=Falsemid.shift_to_elem((l.fetch_index() + r.fetch_index()) // 2Another possible improvement from overloading operators is to overload
__getitem__and__setitem__forMArray. Using these two methods, we could directly access theMArrayElementinside theMArraythrough the bracket operator, thus making animations onMArrayElementin an easier way.I'm not sure about your ideas for these modifications, but if you think they are helpful, I can make a PR on that.
Beta Was this translation helpful? Give feedback.
All reactions