|
ESPHome 2026.2.4
|
A filter that maps values from one set to another. More...
#include <filter.h>
Public Member Functions | |
| MapFilter (const std::initializer_list< Substitution > &mappings) | |
| bool | new_value (std::string &value) override |
Public Member Functions inherited from esphome::text_sensor::Filter | |
| virtual void | initialize (TextSensor *parent, Filter *next) |
| Initialize this filter, please note this can be called more than once. | |
| void | input (std::string value) |
| void | output (std::string &value) |
Protected Attributes | |
| FixedVector< Substitution > | mappings_ |
Protected Attributes inherited from esphome::text_sensor::Filter | |
| friend | TextSensor |
| Filter * | next_ {nullptr} |
| TextSensor * | parent_ {nullptr} |
A filter that maps values from one set to another.
Uses linear search instead of std::map for typical small datasets (2-20 mappings). Linear search on contiguous memory is faster than red-black tree lookups when:
Benchmark results (see benchmark_map_filter.cpp):
Benefits over std::map:
Break-even point: ~35-40 mappings, but ESPHome configs rarely exceed 20
|
explicit |
Definition at line 95 of file filter.cpp.
|
overridevirtual |
Implements esphome::text_sensor::Filter.
Definition at line 97 of file filter.cpp.
|
protected |