Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 69015

Uneven 2-D Array

$
0
0

I would like to start off by stating that I KNOW that 2-D arrays have n by m dimensions.  What I need is illustrated below.  Does anyone know a simple way of implementing this?  I cannot think of an elegant solution:

 

Original Array

[a]  [b]  [c]  [d]  [e]

[f]  [g]  [h]  [i]  [j]

[k]  [l]  [m]  [n]  [o]

[p]  [q]  [r]  [s]  [t]

 

 

Then remove an element [n].  (element array[2][3])

 

 

[a]  [b]  [c]  [d]  [e]

[f]  [g]  [h]  [i]  [j]

[k]  [l]  [m]  [o]  XXX  <--  Notice that [o] moved over, and this row now only holds 4 elements

[p]  [q]  [r]  [s]  [t]

 

Then remove an element [k].  (element array[2][0])

 

[a]  [b]  [c]  [d]  [e]

[f]  [g]  [h]  [i]  [j]

[l]  [m]  [o]  XXX  XXX  <--  Notice that [l][m][o] all moved over, and this row now only holds 3 elements

[p]  [q]  [r]  [s]  [t]

 

Etc...

 

Is this feasible?  And if so, what do you recommend as an approach? 

 

Ideally I would like to be able to add and remove from the arrays and if a row is completely removed, then the row is completely removed.  I.E.  There would only be 3 rows (index [0-2]) if I also removed [l], [m], and [o]. 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

 

Edit: 

 

Does LabVIEW have a linked-list style data stucture?

 

After more brainstorming I think something like this would work in C:

 

Original Linked-List of Linked-Lists  (2-D array implemented via Linked stuctures)

 

[a]->[b]->[c]->[d]->[e]

 ↓

[f]->[g]->[h]->[i]->[j]

 ↓

[k]->[l]->[m]->[n]->[o]

 ↓

[p]->[q]->[r]->[s]->[t]

 

Remove element [o].

 

[a]->[b]->[c]->[d]->[e]

 ↓

[f]->[g]->[h]->[i]->[j]

 ↓

[k]->[l]->[m]->[n]-XXX

 ↓

[p]->[q]->[r]->[s]->[t]

 


Viewing all articles
Browse latest Browse all 69015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>