davetcc / simplecollections Goto Github PK
View Code? Open in Web Editor NEWA list based on binary search that works on a very wide range of embedded boards - from Uno up.
License: Apache License 2.0
A list based on binary search that works on a very wide range of embedded boards - from Uno up.
License: Apache License 2.0
On ARM every processor from Cortex-M0 upwards supports LDREX and STREX, this allows the library to be completely thread-safe on a very wide range of ARM boards, even boards with multiple cores. For now this should enable automatically for:
For other processors, users could submit a PR that enabled this support for additional boards.
Would love to see added support for https://github.com/hideakitai/ArxSmartPtr -- as of this moment I believe the issue is that you are one-off of a level of dereferencing, where you have a pointer to type T and then you invoke ->getKey(), which in the case of shared_ptr doesn't utilize its operator->() call since at that point it was reinterpret casted to a pointer to the shared_ptr object, thus attempting to call the shared_ptr's getKey() method (which it doesn't have).
I believe this may just be a limitation of your current design in general, tho, as it would seem it does about the same with a pointer based type, as well.
I was thinking about this exact issue actually the other day actually, and one way to implement support for this is to distinguish between pointer types and value types at the class level (where each class could do the appropriate amount of dereferencing based on T being value type or pointer/shared_ptr type) - I've seen interesting variations on splitting classes into two subclasses based on various properties. ArduinoJSON library, for instance, won't allocate a memory pool for a read-only object (since it won't be modified), but it will for the writeable object (since it might) - doesn't use const but it does suffix the name the object with Const. Even language like ObjC also do this, by having a MutableArray being write-enabled and Array being read-only (with MutableArray inheriting from Array).
Anyways, I realize it's a big ask, but it would be awesome to see support for such things added. I've included a test program illustrating the compilation error I get when I try to use a shared_ptr object directly.
#include <Arduino.h>
#include <SimpleCollections.h>
#include <ArxSmartPtr.h>
#include <assert.h>
using namespace std;
class TestClass {
public:
TestClass(int key) : _key(key) {;}
int getKey() const { return _key; }
private:
int _key;
};
void setup() {
BtreeList<int, shared_ptr<TestClass> > list;
auto instance = make_shared<TestClass>(0);
list.add(instance);
auto instanceRet = list.getByKey(0);
assert(instance.get() == (*instanceRet).get());
}
void loop() {}
and add new tests for the added functionality.
Add support for reading zio_local_definitions.h
from the local source, if it exists.
At the moment, remove is not implemented, it could be useful for some cases however.
Must be fully unit tested before release.
BtreeList's various access methods that do not modify underlying data, such as getByKey, itemAtIndex, capacity, etc., should be declared as const member methods. This allows it to be used in the case where the returned object is a const list, e.g. when you want to save the cost of a list copy constructor so you return your own private list by reference but declared as const to avoid outside modification. In such a case, you should still be able to look up items, get the capacity, etc., without violating C++ qualifiers.
These boards use a different core structure to the mbed based Arduino variant, so I've used the lowlevel API available critical section for core locking while the circular buffer is ticked.
This is a small fix to correct the return type for circular buffer positions.
This will support a buffer where there is a writer position and a reader position, the writer keeps writing no matter what, even if it overwrites the read position. The reader can read whenever there is a difference between read and write position. In normal use the buffer should be sized to avoid wrapping.
Initial support will be:
ESP8266 - CAS emulated
ESP32 - uses CAS
mbed/Arduino mbed - uses CAS
AVR/MKR other - CAS emulated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.