106 lines
1.9 KiB
Arduino
Raw Normal View History

2020-11-27 11:33:55 +01:00
//
// FILE: set_demo.ino
// AUTHOR: Rob Tillaart
// PURPOSE: demo set intersection union and diff
// DATE: 2014-11-09
// URL: https://github.com/RobTillaart/SET
2021-01-29 12:31:58 +01:00
2020-11-27 11:33:55 +01:00
#include "set.h"
2021-01-29 12:31:58 +01:00
2020-11-27 11:33:55 +01:00
Set setA, setB;
volatile bool b;
2021-12-28 10:38:33 +01:00
2020-11-27 11:33:55 +01:00
void setup()
{
Serial.begin(115200);
Serial.print("Start set_demo : ");
Serial.println(SET_LIB_VERSION);
Serial.println();
Serial.println("\n\nintersection test");
randomSeed(1);
2021-01-29 12:31:58 +01:00
setA.clear();
setB.clear();
2020-11-27 11:33:55 +01:00
for (int i=0; i<150; i++)
{
2021-01-29 12:31:58 +01:00
setA.add(random(256));
setB.add(random(256));
2020-11-27 11:33:55 +01:00
}
Serial.println(setA.count());
Serial.println(setB.count());
setA *= setB;
for (int i=0; i<4; i++)
{
2021-01-29 12:31:58 +01:00
for (int j=0; j<64; j++)
{
Serial.print(setA.has(i*64+j));
}
Serial.println();
2020-11-27 11:33:55 +01:00
}
Serial.println(setA.count());
Serial.println();
Serial.println("\n\nunion test");
randomSeed(1);
2021-01-29 12:31:58 +01:00
setA.clear();
setB.clear();
2020-11-27 11:33:55 +01:00
for (int i=0; i<150; i++)
{
2021-01-29 12:31:58 +01:00
setA.add(random(256));
setB.add(random(256));
2020-11-27 11:33:55 +01:00
}
Serial.println(setA.count());
Serial.println(setB.count());
setA += setB;
for (int i=0; i<4; i++)
{
2021-01-29 12:31:58 +01:00
for (int j=0; j<64; j++)
{
Serial.print(setA.has(i*64+j));
}
Serial.println();
2020-11-27 11:33:55 +01:00
}
Serial.println(setA.count());
Serial.println();
Serial.println("\n\ndiff test");
randomSeed(1);
2021-01-29 12:31:58 +01:00
setA.clear();
setB.clear();
2020-11-27 11:33:55 +01:00
for (int i=0; i<150; i++)
{
2021-01-29 12:31:58 +01:00
setA.add(random(256));
setB.add(random(256));
2020-11-27 11:33:55 +01:00
}
Serial.println(setA.count());
Serial.println(setB.count());
setA -= setB;
for (int i=0; i<4; i++)
{
2021-01-29 12:31:58 +01:00
for (int j=0; j<64; j++)
{
Serial.print(setA.has(i*64+j));
}
Serial.println();
2020-11-27 11:33:55 +01:00
}
Serial.println(setA.count());
Serial.println();
Serial.println("done...");
Serial.println();
}
2021-12-28 10:38:33 +01:00
2020-11-27 11:33:55 +01:00
void loop()
{
}
2021-12-28 10:38:33 +01:00
// -- END OF FILE --