## GdaDataModelArray GdaDataModelArray — An implementation of GdaDataModel based on a GArray |

## Stability Level

Stable, unless otherwise indicated

## Functions

GdaDataModel * | gda_data_model_array_new ()
GdaDataModel * | gda_data_model_array_new_with_g_types ()
GdaDataModel * | gda_data_model_array_new_with_g_types_v ()
GdaDataModelArray * | gda_data_model_array_copy_model ()
GdaDataModelArray * | gda_data_model_array_copy_model_ext ()
GdaRow * | gda_data_model_array_get_row ()
void | gda_data_model_array_set_n_columns ()
void | gda_data_model_array_clear ()

## Properties

guint | n-columns | Read / Write
gboolean | read-only | Read / Write

## Types and Values

struct | GdaDataModelArray
struct | GdaDataModelArrayClass
| GdaDataModelArrayPrivate

## Object Hierarchy

        GObject
        ╰── GdaDataModelArray

## Implemented Interfaces

GdaDataModelArray implements GdaDataModel.

## Description

The GdaDataModelArray object is a data model which internally uses a GArray to index all its rows (represented as GdaRow objects). In this data model, all the data is stored in memory, which can be a memory limitation if the number of rows is huge. This type of data model is easy to use to store some temporary data, and has a random access mode (any value can be accessed at any time without the need for an iterator).

## Functions

### gda_data_model_array_new ()

    GdaDataModel *
    gda_data_model_array_new (gint cols);

Creates a new GdaDataModel object without initializing the column types. Using `gda_data_model_array_new_with_g_types()` is usually better.

#### Parameters

cols | number of columns for rows in this data model. |

#### Returns

a pointer to the newly created GdaDataModel.

[transfer full]

### gda_data_model_array_new_with_g_types ()

    GdaDataModel *
    gda_data_model_array_new_with_g_types (gint cols,
                                           ...);

Creates a new GdaDataModel object with the column types as specified.

[skip]

#### Parameters

cols | number of columns for rows in this data model. |
... | types of the columns of the model to create as GType, as many as indicated by `cols` |

#### Returns

a pointer to the newly created GdaDataModel.

[transfer full]

### gda_data_model_array_new_with_g_types_v ()

    GdaDataModel *
    gda_data_model_array_new_with_g_types_v
                                   (gint cols,
                                    GType *types);

Creates a new GdaDataModel object with the column types as specified.

[rename-to gda_data_model_array_new_with_g_types]

#### Parameters

cols | number of columns for rows in this data model. |
types | array of types of the columns of the model to create as GType, as many as indicated by `cols` . | [array]

#### Returns

a pointer to the newly created GdaDataModel.

[transfer full]

Since: 4.2.6

### gda_data_model_array_copy_model ()

    GdaDataModelArray *
    gda_data_model_array_copy_model (GdaDataModel *src,
                                     GError **error);

Makes a copy of `src` into a new GdaDataModelArray object

#### Parameters

src | a GdaDataModel to copy data from |
error | a place to store errors, or `NULL` |

#### Returns

a new data model, or `NULL` if an error occurred.

[transfer full][nullable]

### gda_data_model_array_copy_model_ext ()

    GdaDataModelArray *
    gda_data_model_array_copy_model_ext (GdaDataModel *src,
                                         gint ncols,
                                         gint *cols,
                                         GError **error);

Like `gda_data_model_array_copy_model()`, makes a copy of `src` , but copies only some columns.

#### Parameters

src | a GdaDataModel to copy data from |
ncols | size of `cols` |
cols | array of `src` 's columns to copy into the new array, not `NULL`. | [array length=ncols]
error | a place to store errors, or `NULL` |

#### Returns

a new data model, or `NULL` if an error occurred.

[transfer full][nullable]

Since: 5.2.0

### gda_data_model_array_get_row ()

    GdaRow *
    gda_data_model_array_get_row (GdaDataModelArray *model,
                                  gint row,
                                  GError **error);

Get a pointer to a row in `model`

#### Parameters

model | a GdaDataModelArray object |
row | row number (starting from 0) |
error | a place to store errors, or `NULL` |

#### Returns

the GdaRow, or `NULL` if an error occurred.

[transfer none]

### gda_data_model_array_set_n_columns ()

    void
    gda_data_model_array_set_n_columns (GdaDataModelArray *model,
                                        gint cols);

Sets the number of columns for rows inserted in this model. `cols` must be greated than or equal to 0.

Also clears `model` 's contents.

#### Parameters

model | the GdaDataModelArray. |
cols | number of columns for rows this data model should use. |

### gda_data_model_array_clear ()

    void
    gda_data_model_array_clear (GdaDataModelArray *model);

Frees all the rows in `model` .

#### Parameters

model | the model to clear. |

## Types and Values

### struct GdaDataModelArray

    struct GdaDataModelArray;

### struct GdaDataModelArrayClass

    struct GdaDataModelArrayClass {
    	GObjectClass              parent_class;
    };

### GdaDataModelArrayPrivate

    typedef struct _GdaDataModelArrayPrivate GdaDataModelArrayPrivate;

## Property Details

### The `“n-columns”` property

      “n-columns”                guint

The number of columns in the model.

Flags: Read / Write

Default value: 0

### The `“read-only”` property

      “read-only”                gboolean

Whether data model can be modified.

Flags: Read / Write

Default value: FALSE

## See Also

GdaDataModel