Variable size 2D arrays

Good afternoon everyone.
I need to allocate array of buffers (arrays). Each buffer would be different size. When implementing this in C/C++ it would look like an array of pointers where each pointer would point to a specific array. Each array could be NULL terminated to know exactly where it ends.
How can I implement this in LabVIEW? Two dimentional arrays are an option, but would waste a lot of memory since the second dimmention would have to be the dimmention of the largest buffer.
Please help.
Thank you in advance,
BorisMoto

Well, you can use an array of clusters, where each cluster holds a 1D array. I think this would take less memory but it would definitly be more complex becuase you're adding the cluster operations. To do this, create a 1D array, drag it into a cluster and drag that cluster into another array. It's possible that this isn't any better. You can measure the performance difference by using VI profiling (Tools>>Advanced) and by using timing (the time the VI stopped minus the time it started).
Try to take over the world!

Similar Messages

  • Variable size array in a FlowPane

    If i have an array of variable size (for example a array of cards).
    How can i build something to show the elements(in a FlowPane for example) and each of them having its own controller (fxml + controller for each card), so the container (flow pane) of the elements (cards) can have it's elements swaped, removed or added new ones?
    Controller:
    public class HandController extends FlowPane implements Initializable{
        @Override public void initialize(URL arg0, ResourceBundle arg1){
        public void setHand(ArrayList<Cards> Hand){
            //this would work if the hand were static
            for(int i = 0; i < Hand.size(); ++i){
                FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("CardView.fxml"));
                CardController controller = new CardController();
                fxmlLoader.setController(controller);
                fxmlLoader.setRoot(controller);
                Parent card = (Parent)fxmlLoader.load();
                fxmlLoader.setRoot(card);
                this.getChildren().add(card);
                controller.setCard(Hand.get(i));
    }Fxml:
    <fx:root type="FlowPane" xmlns:fx="http://javafx.com/fxml"
             stylesheets="view/Style.css">
        <children>
            <!--should i put something here?-->
        </children>
    </fx:root>

    Well, I was bored...
    This "game" has a hand of up to five cards. You can deal from a deck to the hand, and then play (or discard) a card by double-clicking on it.
    The model comprises a Card class, a Deck class, and a GameModel class. The last one tracks the hand and deck and the relationship between them. Card and Deck were written from my memory of reading an example of using Enums by Josh Bloch.
    Card.java
    package cardgame;
    public class Card {
         public enum Rank {
              Ace, Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King
         public enum Suit {
              Clubs, Diamonds, Hearts, Spades
         private final Rank rank;
         private final Suit suit;
         public Card(Rank rank, Suit suit) {
              this.rank = rank;
              this.suit = suit;
         public Rank getRank() {
              return rank;
         public Suit getSuit() {
              return suit;
         @Override
         public String toString() {
              return String.format("%s of %s", rank, suit);
         @Override
         public int hashCode() {
              final int prime = 31;
              int result = 1;
              result = prime * result + ((rank == null) ? 0 : rank.hashCode());
              result = prime * result + ((suit == null) ? 0 : suit.hashCode());
              return result;
         @Override
         public boolean equals(Object obj) {
              if (this == obj)
                   return true;
              if (obj == null)
                   return false;
              if (getClass() != obj.getClass())
                   return false;
              Card other = (Card) obj;
              if (rank != other.rank)
                   return false;
              if (suit != other.suit)
                   return false;
              return true;
    }Deck.java
    package cardgame;
    import java.util.ArrayList;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Random;
    import cardgame.Card.Rank;
    import cardgame.Card.Suit;
    public class Deck {
         private final List<Card> cards;
         private Deck() {
              cards = new LinkedList<Card>();
              for (Suit suit : Suit.values())
                   for (Rank rank : Rank.values())
                        cards.add(new Card(rank, suit));
         public static Deck newDeck() {
              return new Deck();
         public static Deck shuffledDeck() {
              return newDeck().shuffle();
         public Deck shuffle() {
              final List<Card> copy = new ArrayList<Card>(cards.size());
              Random rng = new Random();
              while (cards.size() > 0) {
                   int index = rng.nextInt(cards.size());
                   copy.add(cards.remove(index));
              cards.clear();
              cards.addAll(copy);
              return this;
         public Card deal() {
              return cards.remove(0);
         public int size() {
              return cards.size();
    }GameModel.java
    package cardgame;
    import javafx.beans.binding.BooleanBinding;
    import javafx.beans.property.BooleanProperty;
    import javafx.beans.property.ReadOnlyBooleanProperty;
    import javafx.beans.property.SimpleBooleanProperty;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    public class GameModel {
         private ObservableList<Card> hand;
         private Deck deck;
         private BooleanProperty canDeal;
         public GameModel() {
              this.hand = FXCollections.observableArrayList();
              this.deck = Deck.newDeck().shuffle();
              this.canDeal = new SimpleBooleanProperty(this, "canDeal");
              canDeal.bind(new BooleanBinding() {
                        super.bind(hand);
                   @Override
                   protected boolean computeValue() {
                        return deck.size() > 0 && hand.size() < 5;
         public ObservableList<Card> getHand() {
              return hand;
         public ReadOnlyBooleanProperty canDealProperty() {
              return canDeal;
         public boolean canDeal() {
              return canDeal.get();
         public void deal() throws IllegalStateException {
              if (deck.size() <= 0) {
                   throw new IllegalStateException("No cards left to deal");
              if (hand.size() >= 5) {
                   throw new IllegalStateException("Hand is full");
              hand.add(deck.deal());
         public void playCard(Card card) throws IllegalStateException {
              if (hand.contains(card)) {
                   hand.remove(card);
              } else {
                   throw new IllegalStateException("Hand does not contain " + card);
    }The CardController is the controller for a CardView. It takes a reference to a Card and its initialize method initializes the view to display it (the view is just a simple label).
    CardController.java
    package cardgame;
    import javafx.fxml.FXML;
    import javafx.scene.control.Label;
    public class CardController {
         private final Card card;
         @FXML
         private Label label;
         public CardController(Card card) {
              this.card = card;
         public void initialize() {
              label.setText(String.format("%s%nof%n%s", card.getRank(),
                        card.getSuit()));
    }The HandController is the controller for the display of the hand. This is where most of the action happens. The trick here is that it requires a reference to a GameModel, which needs to be injected from somewhere, so we need a setModel(...) method, or something similar. I didn't want to assume the order of events: i.e. whether the model is injected before or after the initialize() method is invoked. To keep this flexibility, I used an ObjectProperty to wrap the model, and listen for changes to it. When the model is updated, I register a listener with the hand (exposed by the model). This listener in turn rebuilds the views of the cards when the hand changes. There's also a "deal" button, whose disabled state is managed by binding to a property in the model (using a neat trick from the Bindings class to allow the model value to be dynamic).
    HandController.java
    package cardgame;
    import java.io.IOException;
    import javafx.beans.binding.Bindings;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.ListChangeListener;
    import javafx.event.EventHandler;
    import javafx.fxml.FXML;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Node;
    import javafx.scene.control.Button;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.Pane;
    public class HandController {
         private ObjectProperty<GameModel> model;
         @FXML
         private Pane container;
         @FXML
         private Button dealButton;
         public HandController() {
              this.model = new SimpleObjectProperty<GameModel>(this, "model", null);
              final ListChangeListener<Card> handListener = new ListChangeListener<Card>() {
                   @Override
                   public void onChanged(Change<? extends Card> change) {
                        container.getChildren().clear();
                        try {
                             for (Card card : model.get().getHand()) {
                                  container.getChildren().add(loadCardView(card));
                        } catch (IOException e) {
                             e.printStackTrace();
              model.addListener(new ChangeListener<GameModel>() {
                   @Override
                   public void changed(
                             ObservableValue<? extends GameModel> observable,
                             GameModel oldValue, GameModel newValue) {
                        if (oldValue != null) {
                             oldValue.getHand().removeListener(handListener);
                        if (newValue != null) {
                             newValue.getHand().addListener(handListener);
         public void setModel(GameModel model) {
              this.model.set(model);
         public void initialize() {
              dealButton.disableProperty().bind(
                        Bindings.selectBoolean(model, "canDeal").not());
         private Node loadCardView(final Card card) throws IOException {
              FXMLLoader loader = new FXMLLoader(getClass().getResource(
                        "CardView.fxml"));
              CardController controller = new CardController(card);
              loader.setController(controller);
              Node cardView = (Node) loader.load();
              cardView.setOnMouseClicked(new EventHandler<MouseEvent>() {
                   @Override
                   public void handle(MouseEvent event) {
                        if (event.getClickCount() == 2) {
                             model.get().playCard(card);
              return cardView;
         public void dealCard() {
              model.get().deal();
    }Here are the FXML files:
    CardView.fxml
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.StackPane?>
    <?import javafx.scene.control.Label?>
    <?import java.lang.String?>
    <StackPane xmlns:fx="http://javafx.com/fxml" prefHeight="150" prefWidth="80" minWidth="80" maxWidth="80" minHeight="150" maxHeight="150">
         <Label fx:id="label" >
         </Label>
         <styleClass>
              <String fx:value="card"/>
         </styleClass>
    </StackPane>Hand.fxml
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.FlowPane?>
    <?import javafx.scene.layout.BorderPane?>
    <?import javafx.scene.control.Button?>
    <?import javafx.scene.control.ScrollPane?>
    <?import java.lang.String?>
    <BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="cardgame.HandController" >
         <center>
              <FlowPane hgap="5" vgap="10" fx:id="container">
              </FlowPane>
         </center>
         <bottom>
              <Button text="Deal" onAction="#dealCard" fx:id="dealButton"/>
         </bottom>
    </BorderPane>The overall application is managed by a Game.fxml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.BorderPane?>
    <BorderPane xmlns:fx="http://javafx.com/fxml" fx:controller="cardgame.GameController">
         <center>
              <fx:include source="Hand.fxml" fx:id="hand" />
         </center>
    </BorderPane>with a GameController:
    package cardgame;
    import javafx.fxml.FXML;
    public class GameController {
         @FXML private HandController handController ;
         private GameModel model ;
         public GameController() {
              model = new GameModel();
         public void initialize() {
              handController.setModel(model);
    }Game.java is the main class:
    package cardgame;
    import java.io.IOException;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    public class Game extends Application {
         @Override
         public void start(Stage primaryStage) throws IOException {
              Scene scene = new Scene(FXMLLoader.<Parent>load(getClass().getResource("Game.fxml")), 600, 400, Color.DARKGREEN);
              scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm());
              primaryStage.setScene(scene);
              primaryStage.show();
         public static void main(String[] args) {
              launch(args);
    }and then a style sheet
    style.css:
    @CHARSET "US-ASCII";
    .card {
         -fx-background-color: white ;
         -fx-border-color: black ;
         -fx-border-radius: 5 ;
         -fx-border-style: solid ;
         -fx-padding: 5 ;
    .card .label {
         -fx-text-alignment: center ;
    }

  • How can I create a variable size array?

    How can I create a variable size array?

    ok then how can i create a new vector object?If you don't know that, you need to go back to your text book and study some more. Or read the tutorial on the basics of Java: http://java.sun.com/docs/books/tutorial/java/index.html
    After reading that you can move on to: http://java.sun.com/docs/books/tutorial/collections/index.html
    Anyway, the answer to your question is, of course:
    Vector v = new Vector();(But you should probably use ArrayList instead of Vector.)

  • How do i send an array of clusters with variable size over TCP/IP?

    Hi,
            I'm trying to send an array of clusters with varible size over TCP/IP,. But I'm facing the following problems:
    1) I need to accept the size of array data from the user and increase the size dynamically.
    I'm doing this using the property node but how do I convey the new size to my TCP read?
    2) I need to wire an input to my 'bytes to read' of the TCP read.
    But the number of bytes to read changes dynamically
    How do I ensure  the correct number of bytes are read and reflected on the client side?
    3) Is there anyway I can use global varibles over a network such that their values are updated just as if they would on one computer?
     Will be a great help if someone posts a solution!
    Thank you...

    twilightfan wrote:
    Altenbach,
     ... xml string. ...number of columns that I'm varying using property node s... I solved these problems by using a local variable as the type input ...o TCP read is creating a problem.... second TCP read gets truncated data because
    its no longer just the first four bytes that specify the length of the data, it could be more as my array of cluster can be pretty huge.
    Instead of writing long and complicated sentences that make little sense, why don't you simply show us your code? 
    What does any of this have to do with xml strings???? I don't see how using a local variable as type input changes anything. The user cannot interact with "property nodes", just with controls. Please clarify. Once the array of clusters is flattened to a string you only have one size that describes the size of the data, no matter how huge it is (as long as it is within the limits of I32). Similarly, you read the string of that same defined length and form the array of clusters from it. How big are the strings? What is your definition of "huge"?
    Here's is my earlier code, but now dealing with an array of clusters. Not much of a change. Since you have columns, you want 2D. Add as many diensions you want, but make sure that the control, diagram constant, and indicator all match.
    The snipped shows for a 1D array, while the attached VI shows the same for a 2D array. Same difference.  
    Message Edited by altenbach on 01-31-2010 01:13 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    FlattenArrayOfClusters.vi ‏12 KB
    ioclusters3MOD.png ‏25 KB

  • Variable Size Error.

    Hi Experts,
    I am using a variable to get the error message and use that in sending mail, but when i ran the scenario its error out saying,
    "ORA-12899: value too large for column".
    My assumption is when the error message exceed more than 200 characters its error out. So my question is how to increase the size of the variable size?
    Please help..
    Thanks

    Hi G,
    Thanks for your reply,
    Datatype : AlphaNumeric
    Action: Historize (I tried Not Persistance, last value also).
    please let me know if you need anything.

  • Variable size item problem in BOM

    hi all,
    We have semi-finished material with componets as variable size items (item cat. R)
    Now in the variable size tem data, Size 1 = 1,406 MM, Size 2 = 1,220 MM. Numner is 1 ST, formaula place is blank.
    Qty Var-Sz Item is calculated by system is 3.957 M2. On what basis this value is calculated?
    In the component material we have maintained a componenet scrap quantity as 15%.
    BOM ratio of header : component = 1NOS : 1 ST
    Again when we create a production order for the header, for 1 NOS header quantity component qty becomes 2.
    For 2 NOS of header qty, component becomes 3 like this.
    Why this happens..
    Regards,
    Srijit.

    Thread closed

  • Variable size item:

    Hi
    Company procures copper sheet of certain thickness with different sizes. Stock keeping dimension is KG. Material master has alternative unit of measure and conversion factor for KG and cubic centimeter. Design department will enter this sheet dimension like 15005003 in BOM and it will correctly calculate KG with formula entered.
    My problem is shop floor person will come to know the dimension and KG relation but how store person will come to know what size he has to cut and issue against production order. As while issuing goods he can only see quantity in KG and not in cubic centimeters ?
    Surendra

    SDBSAP ,
    If its unanswered why you flaged it answered .......?
    and solution to your problem in standard sap is not possible.
    You need to go for development, logic can be , for all variable size items from a BOM you need to pick size 1 size 2 and size 3 to print on issue slip . It will give exact dimension to your storage person to issue the correct dimension sheet to shop floor.
    Regards
    Ritesh

  • Variable size items.

    Hi, im a PP consultant from bombay, i had a query regarding a client who is inti\o wooden frame manufacturing it is a strictly discrete industry and the client specifications vary with almost every request. at the moment the client is creating a new mat master for every new product thus causing the master materials to run into 50-60 thousand currently. i want to know if i can use variable size items to reduce the number of materials defined as all of the materials are from standard sized planks. stock is required to be maintained for all components individually.

    Hi,
    "If you want different-sized sections of a material (raw material) to be represented by one material number in BOM items, you use this item category."
    Ans lies in the your last statement(stock is required to be maintained for all components individually)You cannot go for variable size item as you need to maintain stock individually
    Revert if you have further query
    Reward points if useful
    Regards,
    SVP

  • Variable size memory is not matching....

    Hello, Here is my oracle version..
    Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
    PL/SQL Release 10.1.0.2.0 - Production
    CORE 10.1.0.2.0 Production
    TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
    NLSRTL Version 10.1.0.2.0 - Production
    My variable size memory should be exactly same as Java pool, large pool, shared pool.
    scott@orcl> show sga
    Total System Global Area 171966464 bytes
    Fixed Size 787988 bytes
    Variable Size 145488364 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 524288 bytes
    scott@orcl> select
    2 sum(bytes)
    3 from
    4 v$sgastat
    5 where
    6 pool in ('shared pool', 'java pool', 'large pool');
    SUM(BYTES)
    143369796
    The stream pool size should be part of SGA. But it is not showing in v$sgastat view....
    In oracle9i, variable size was matching with the above query. Now it is not matching..
    Am i missing any thing in my above query? Any help is highly appreicated...

    still it is not matching... variable size is 145488364 bytes... but the below is showing 142606336.
    scott@orcl> show sga
    Total System Global Area 171966464 bytes
    Fixed Size 787988 bytes
    Variable Size 145488364 bytes
    Database Buffers 25165824 bytes
    Redo Buffers 524288 bytes
    scott@orcl> select sum(bytes) from v$sgainfo where name in('Streams Pool Size',
    2 'Java Pool Size','Large Pool Size','Shared Pool Size');
    SUM(BYTES)
    142606336
    scott@orcl>
    scott@orcl> select * from v$sgainfo;
    NAME BYTES RES
    Fixed SGA Size 787988 No
    Redo Buffers 524288 No
    Buffer Cache Size 25165824 Yes
    Shared Pool Size 83886080 Yes
    Large Pool Size 8388608 Yes
    Java Pool Size 50331648 Yes
    Streams Pool Size 0 Yes
    Granule Size 4194304 No
    Maximum SGA Size 171966464 No
    Startup overhead in Shared Pool 29360128 No
    Free SGA Memory Available 0
    11 rows selected.
    scott@orcl>

  • Variable size item formulla key funtion module,

    I am developing user interface for manual reservation (cutsom development). User wants to calculate quantity of material if he enters size1, size2 and size3. Also he wants that a formula key option to be provided so that he can mention conversion formula. Is there any standard function module for variable size formulla funtion module.
    I want to use same logic of variable size item formulla of bom in the above custom template.
    Please suggest.

    Hi
    The function module EVAL_FORMULA and FORMULA_EVALUATION may help you as they all export calculated values as output. Please go to SE37 to click the button 'Function module documentation' to see more information.
    Or go to SE80 to check the function group CALC to see more function.
    Best Regards
    Leon.

  • Variable size item Vs Stock item

    Hi Experts,
    I have a doubt regarding the use of variable size item over standard stock item. I will give an example as under.
    I have an item called cable which is to be added to a header material. This cable will be used in many header materials. I tried using variable size item as an item category and given the following parameters
    Size 1 as 5 M(UOM)
    Formula (L1)
    Number (1) ST
    System calculates the value as 5 M for qty var sz item
    In the item over view screen, quantity against the material 1 ST
    My query is instead of giving the qty as 5 M and use a formula, what if i directly give the item as stock item "L" and directly define the qty as 5M. If there is no difference between the above, why should we use the variable size item? instead we can directly calculate and give the qty for the item right. Kindly clarify the application of variable size item over standard stock item category.
    In both the cases I will be having one material code in the system and the qty will be changed in the respective BOM of two different header materials.
    Regards,
    Sridharan M

    Hi
    In addition to the stock keeping unit you can provide the details like length, width and thickness, say for example if you want to fabricate a metal part. You may need length width and thickness of the plate to be used for fabrication. This details you will be entering in the variable size items and using the formual you can calculate the required quantity in KG.
    This kind of variable size items you need not calcualte the weight of the material you just need to enter the sizes as per the drawing as you prepare the BOM.
    This varies with respect to size.... Variable Size Items
    Soundar

  • Variable size material assigning problem

    Hi friends,
    I am trying to assign a variable size material for an activity. There is a scenario in which they are giving only one dimension and no formula is been used to calculate but the required qty field is rounding off for next decimal point for eg: if the size of material i am giving as 0.912 mm then the required qty is round off to 0.920. Can any one please tell me do we have any config setting to be done to take out this rounding off decimal point.
    Thanks
    Satish.

    the data element for required quantity CO_MENGE has 3 places of decimal - so basically it should be fine
    I have checked in my system and I can see 0.912 for a material with dimension length
    the other thing is check the material master - additional data for units of measure - or there might be some program rounding off the units to 2 digits
    If you are using a custom unit then check CUNI and make sure it is not set to 2 decimal places

  • Variable Size Item Data in Purchase Requisition

    Hi
    When ever the Purchase Requisition of the Variable size material is
    raised, how do i view,for reference,the Variable Size Item data from
    Bill of materials .
    Steps for the Reconstruction 
    1.Create a Variable size Item Bill of material.
    2.Run MRP agianst the Variable size material's dependent demand.
    3.View the Purchase requisition of the Variable size Item, to take a
    note of the Item Data.

    Thread closed

  • Variable size material

    how we create variable size material
    thanks in advance

    Dear,
    T-Code-CS01
    1. Enter the material for which you want to create BOM, Plan and BOM usage.
    2. Select the item category "R", enter the component. Now you will be taken to the "Variable item data" screen.
    3. Enter the datas of Size 1, 2 & 3 (as required) and the unit of the size & number. System will calculate the "Qty of var- size item" in the unit assigned to the basic data of the material master of the component.
    4. Save
    You can change the unit of the variable size item as per your requirement in OS28
    Regards,
    R.Brahmankar

  • Storage location selection for variable size item

    Hi All
    There is a BOM of finished good Material "XYZ" and there is a component "A" in the BOM. This Component A is a variable size item, its a metallic bar of length 4 meters.  In BOM XYZ, only 1.5 meters is consumed.
    Now when a production order is made for XYZ and the confirmation is done with movement type 261. All the materials are backflushed along with component A . The client's requirement is to transfer the remaining length of component A (i.e. 4 - 1.5 = 2.5 meters ) to a different storage location at the time of confirmation.
    Please let me know how is it possible.
    Thanks in Advance
    Rohit

    FULL STEPS:
    1.first do mb1b 311 mvmt transfer posting  for the components from raw-stor location to prod stor location. you can do for A
    2.  do GI for the components. for A for that final product . consume 1.5 so. the remaining component will be (3 ) there in the stor. location as per sap. (check in mmbe)
    3. then do mb1b 311   transfer posting for the A component to raw-stor location. from the prod stor location.
    or rever the  transfer posting mb1b 312.

Maybe you are looking for