digitalmars.D.learn - Arrays
- Patrick (8/8) Mar 16 2007 I have a list of vectors and I want to be able to add a vector through a...
- Frits van Bommel (7/16) Mar 16 2007 Why would wrapping it in a simple struct not "feel right"? That's how
- Patrick (6/23) Mar 16 2007 A struct which only contains one array of floats:
- Jarrett Billingsley (5/11) Mar 16 2007 If it makes you feel any better, that won't change the size or behavior ...
- Patrick (2/16) Mar 17 2007
I have a list of vectors and I want to be able to add a vector through a function like this: float[3] giveVector(); ----- float[][3] vectorList; vectorList ~= giveVector(); ----- Any ideas on how to implement this? It doesnt really feel right to wrap the vector up in a class or struct...
Mar 16 2007
Patrick wrote:I have a list of vectors and I want to be able to add a vector through a function like this: float[3] giveVector(); ----- float[][3] vectorList; vectorList ~= giveVector(); ----- Any ideas on how to implement this? It doesnt really feel right to wrap the vector up in a class or struct...Why would wrapping it in a simple struct not "feel right"? That's how vectors are typically implemented in D, judging by posts in these newsgroups. (Hint: you may want to search these groups to see how others have implemented vectors & matrices to avoid reinventing the wheel for the Nth time)
Mar 16 2007
A struct which only contains one array of floats: struct Vector { float[3] containingElements; } I may be too finicky but it really seems like codebloat to me. But if there arent any other solutions... Frits van Bommel Wrote:Patrick wrote:I have a list of vectors and I want to be able to add a vector through a function like this: float[3] giveVector(); ----- float[][3] vectorList; vectorList ~= giveVector(); ----- Any ideas on how to implement this? It doesnt really feel right to wrap the vector up in a class or struct...Why would wrapping it in a simple struct not "feel right"? That's how vectors are typically implemented in D, judging by posts in these newsgroups. (Hint: you may want to search these groups to see how others have implemented vectors & matrices to avoid reinventing the wheel for the Nth time)
Mar 16 2007
"Patrick" <spam spam.at> wrote in message news:etevk0$1cu6$1 digitalmars.com...A struct which only contains one array of floats: struct Vector { float[3] containingElements; } I may be too finicky but it really seems like codebloat to me. But if there arent any other solutions...If it makes you feel any better, that won't change the size or behavior of the vector at all. It'll still be 12 bytes and passed by value. But the nice thing is that you can then add methods to the vector struct. :\
Mar 16 2007
Thanks! I was just now thinking about that. Jarrett Billingsley Wrote:"Patrick" <spam spam.at> wrote in message news:etevk0$1cu6$1 digitalmars.com...A struct which only contains one array of floats: struct Vector { float[3] containingElements; } I may be too finicky but it really seems like codebloat to me. But if there arent any other solutions...If it makes you feel any better, that won't change the size or behavior of the vector at all. It'll still be 12 bytes and passed by value. But the nice thing is that you can then add methods to the vector struct. :\
Mar 17 2007