www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Hookable Swap

reply Era Scarecrow <rtcvb32 yahoo.com> writes:
Making a struct type/array that visually outputs and displays 
compares/mutations of a type. While using the library sorting 
functions (which relies on std.algorithm.mutation.swap) it 
doesn't call opAssign and doesn't pass through the struct. (which 
also changes the indexes which it shouldn't).

Is there a struct override or function that forces it to be 
called for swapping or changes? Or do i simply have to detect 
changes between compares?
May 18 2019
parent reply Era Scarecrow <rtcvb32 yahoo.com> writes:
On Sunday, 19 May 2019 at 06:13:13 UTC, Era Scarecrow wrote:
 Making a struct type/array that visually outputs and displays 
 compares/mutations of a type. While using the library sorting 
 functions (which relies on std.algorithm.mutation.swap
Well been having fun with sorting and more of this; Added a function that with compares it checks if the indexes have changed (saying the item has changed) and acts accordingly. So now the compared spots look right. Here's some outputs if you are interested https://pastebin.com/raw/QWn6iDF3
May 19 2019
parent Era Scarecrow <rtcvb32 yahoo.com> writes:
On Monday, 20 May 2019 at 02:18:51 UTC, Era Scarecrow wrote:
 Here's some outputs if you are interested
Noticing how Heapify moves a large portion of areas more or less in their location, doing heapify before binary insertion sort lowers how much moving goes on quite a bit. Doing 2 heapify's dropped in my test down a lot. An interesting idea to throw in partial ideas from other sorts to make a more efficient one. So binary insertion sort heap(min): BISH Some experiments to be done, but looks interesting. Sorting a 44 character string/array (quick brown fox) took about 250 comparisons and similar moves. I removed a bunch that are likely an assert in the final check/run of the heapify. Original binary insertion sort was 154 comparisons and 466 moves. Bish sort was 259 & 284 moves https://pastebin.com/raw/rJ1aWmD1
May 19 2019