Say I have collection Cars. Every time I insert a new Car, I want it to be automatically labeled as "Car_${Cars.length}". Every time, I remove a Car from Cars, I want to label to be adjusted accordingly:Before removed:Car_1 Car_2 Car_3 <--- To be removed Car_4 Car_5 After:Car_1 Car_2 Car_3 Car_4 So after Car_3 has been removed, Car_4 and Car_5 label are readjusted accordingly.Now, what's the best way to implement this? I know I can loop through the collection and reassign the label but that doesn't seems like a good idea in term of performance
Submitted July 26, 2020 at 04:37AM by kumagaitaro
No comments:
Post a Comment