Parallel Protocol Hierarchies

I am trying to build a hierarchy of protocols that reference each other. Here is a code fragment that explains my predicament...


// First I have a hierachy of protocols to represent my data and managing access to it

protocol A {} // Placeholder for future functionality



protocol AChildP {

    var i:   Int { get }

}



typealias BigThings = Int // These will be much bigger than Ints



struct AChild : A {

    var i:   BigThings

}

// I will add funcs here operating on A to manage the data in AChild



// Next: Some big collection of AChilds - let say an Array for now

let AChilds : Array< AChild > = [ AChild(i:1), AChild(i:2), AChild(i:3) ]

    // This will a huge array so when I head over to accessing it from B I only want to reference it



// Secondly I want a parallel set of protocols to interpret my data. I don't want to copy it

protocol B {

    associatedtype U where U == A // I want the base protocols to be constrained to each other (I think!)

}



protocol BChildP : B {

    var s: String { get }

}



// This is where I get stuck...

// If this were OO then perhaps I would create an Array (or whatever collection type I used with AChilds) of objects

//  that in turn pointed to a corresponding AChild and then referenced the AChilds.

// I could do that here too with a Class I think



// However, I want to stay with Structs - but they are value things. I cant seem to work out how to tie a

//  BChild to its correcponding AChild without a copy being made.

Any helpful pointers (ha) would be appreciated.

Programming is a science and not an art. Please read the swift documentation.

Be as that may, I am looking for a creative solution to my problem, not inherently inferable from reading the documents that you reference. I have received the brushes, canvas and the paint --- I now need the help of the masters to craft my work.

Parallel Protocol Hierarchies
 
 
Q