What is the equivalent of dictionary structure

What is the equivalent of dictionary structure Of key Value pairs?

I am not sure what you mean by this question.

The structure that takes a key to a value is a map. There are many kinds of maps. The particular kind of map depends upon whether there is an array or a linked list or some other database, whether concurrent reads and writes are permitted, how efficient the concurrency needs to be, etc.

Ok how can i store 10 sets of temp, humidity values, like:

dataArray = { {t1,h1}, {t2,h2}, {t3,h3} };

I've got this so far:

int smsSampleCount=0;

void MainAlarm(){
  Serial.println("Main Alarm...");
  
  double temp = 59.0 + smsSampleCount;
  double hum = 99.0  + smsSampleCount;

  //Store data in array 8 times
  double dataArray[10];
  if (smsSampleCount<8) { 
    //Add this data to array
    dataArray[0]=temp;//,humString
  }
  sendData(dataArray);
}

Perhaps it is time to learn about C/C++ struct. There may also be an array of struct.

Interesting code, but without knowing its purpose and the definition of its functions, it is meaningless to me.

Since it looks like you want to group Temp/Humidity pairs, I'd go with an array of structures.

Marciokoko:
What is the equivalent of dictionary structure Of key Value pairs?

If you mean something equivalent to a Python dictionary or a Ruby hash then my feeling is that it would be difficult to implement in the small memory of an Arduino.

As others have said, a struct is probably the way to go - but it won't have the dynamic nature of a Python dictionary.

...R

So what about storing them like:

dataArray= { {T1,H1}, {T2,H2}, ...};

How do I make sure they are ordered in the order they were sampled?

It seems that you are proposing a two dimensional array. That could work. You allocate the array and you choose where in the array data is stored.

Marciokoko:
How do I make sure they are ordered in the order they were sampled?

That is an interesting question in the context of the Thread title because the one thing that is NOT known with a Python dictionary (or a Ruby hash) is the order in which the items are stored.

However with an array there is no difficulty determining the order.

...R

Well originally I thought of a dictionary because I was thinking of a dictionary of arrays:

{ timestamp= [T,H],
timestamp = [T,H],
timestamp = [T,H]
}

I should've expressed my idea more clearly. So I should just store each item in the array using the index. What Im confused about is the following.

void MainAlarm(){
  Serial.println("Main Alarm...");
  
  double temp = 59.0 + smsSampleCount;
  double hum = 99.0  + smsSampleCount;

  //Store data in array 8 times
  double dataArray[2];
  double sampleArray[10];
  if (smsSampleCount<8) { 
    sampleArray[0]=temp;
    sampleArray[1]=hum;
    dataArray[smsSampleCount] = sampleArray;
  }
  sendData(dataArray);
}

Yes, that is confusing.
Why not a single 2-D array?

I'll be darned if I can understand what smsSampleCount is or why it is added to temp and hum.

Perhaps something like this.

typedef struct {
  uint32_t timeStamp;
  float tempSample;
  float humditySample;
} samplePoint;

samplePoint tempHumidityData[10];

I just used an array size of 10 as an example. It's unclear from your code what you really need.

smsSampleCount is a counter, to make sure each dataArray contains 9 sampleArray objects. The dataArray will look like:

dataArray = [ {1,1},{2,2},{3,3},{4,4},{5,5},{6,6},{7,7},{8,8} ]

I just added the counter to the fake hardcoded data points to have different values in this test code. In reality those values will come form the sensor of course.

C++ has some standard libraries with various implemetations of map. I haven't used them, so I don't know much about them.

Why do you want to do this?

Ok how can i store 10 sets of temp, humidity values, like:

dataArray = { {t1,h1}, {t2,h2}, {t3,h3} };

Oh. So are you using a temperature value as a key? You will have one element for each possible temperature value?

I'm guessing that what you are probably trying to do is some sort of interpolation. Given a temp, find a corresponding humidity.

Normally I'd have an array of structs (or just two arrays), and do a binary chop search to find the interval containing the target temperature.

Thanks guys, I think gfvalvo's suggestion it whats seems easiest to me and I guess what I was looking for. Ill gave it a try but I get a " assigning to an array from an initializer list" error:

int smsSampleCount=0;

typedef struct {
  uint32_t timeStamp;
  float tempSample;
  float humditySample;
} samplePoint;

samplePoint tempHumidityData[10];
void setup() {
  // put your setup code here, to run once:
  tempHumidityData = { millis(), (59+smsSampleCount), (99+smsSampleCount) };

  //Store data in array 8 times
  
  if (smsSampleCount<8) { 
    tempHumidityData[smsSampleCount];
  }
  MainAlarm(tempHumidityData);
}
void MainAlarm(samplePoint array){
  Serial.println("Main Alarm...");
  //Serial.println array;
}

void loop() {
  // put your main code here, to run repeatedly:
}

tempHumidityData = { millis(), (59+You can't do that in C++

I cant do what? Your answer got cut off.

Marciokoko:
I cant do what? Your answer got cut off.

No, it didn't. AWOL pointed out the line in your code that is invalid. There are valid ways to populate an array. And, then there is your incorrect attempt.

Well I used this reference:

http://playground.arduino.cc/Code/Struct

And this is what I came up with:

int smsSampleCount=0;

typedef struct {
  uint32_t timeStamp;
  double tempSample;
  double humditySample;
} samplePoint;

samplePoint tempHumidityData[10];
void setup() {
  double tempTemp = 59;
  double tempHum = 99;
  samplePoint tempHumidityData = { millis(), tempTemp, tempHum };

  //Store data in array 8 times
  
  if (smsSampleCount<8) { 
    tempHumidityData[smsSampleCount];
  }
  MainAlarm(tempHumidityData);
}
void MainAlarm(samplePoint array){
  Serial.println("Main Alarm...");
  //Serial.println array;
}

void loop() {
  // put your main code here, to run repeatedly:
}