Tracking absolute index position durring dimension removal

Alright Julia wizardettes/wizards. While working on my package I keep running into this problem; it’s a book keeping problem and it shows up a lot in numerical methods. Say we have a 2-array/matrix and we want to make comparisons between I don’t know rows in that matrix between columns or something. IE: in a given iteration, depending on the comparison, a column will be removed. Now, at the end of a lot of shuffling and comparing what the end user wants to know about is, “what columns were compared”.

Trivial right? The trick is there’s a moving bed of absolute positions during the algorithm. For example after removal of column say 2, all columns >2 are now N - 1. Problem is still trivial, well I’ve solved it maybe 4 different ways, and I dislike honestly, all of my approaches despite all of them doing what I want. I’ll share one I scribbled up in about 5 minutes below. This isn’t my best approach but its the only one I have that stands on its own. I am actually really tired and shouldn’t be writing/sharing code right now, but am eager to see what others can/have come up with,

mutable struct shieldedindices{ A, B, C }

function (x::shieldedindices)()
    #Ew In is slow here!
    activeset = [ loc in x.Kept for (loc, _) in x.View ];
    return last.( x.View[ activeset ] )

function ShieldedIndices( X )
    len = length( X )
    span = collect( 1 : len )
    return shieldedindices( span .=> X, span, [], len )

function RemoveFromShield( x, i )
    activeset = [ loc in x.Kept for (loc, _) in x.View ];
    corr = [ loc != i for (loc, _) in enumerate( x.View[ activeset ] ) ];
    x.Kept = x.Kept[ corr ]
    return x

function Removed(x)
    findall( [ !(loc in x.Kept) for (loc, _) in x.View ] )

a = [11,22,33,44,55,66,77,88,99];
si = ShieldedIndices(a);

RemoveFromShield(si, 5);
RemoveFromShield(si, 7);