[Bro-Dev] set and vector operators
vern at icir.org
Wed Apr 25 10:40:16 PDT 2018
I'm working on some scripts that use sets and vectors, sometimes together,
and am finding it clunky that Bro doesn't offer much in the way of operators
for this. To that end, I'm thinking of implementing some along the following
lines, where values starting with 's' are sets, 'v' are vectors, and 'e'
are type-compatible elements:
s1 + s2 Set union (for sets of the same type, of course)
s1 || s2 Set union
s1 && s2 Set intersection
s1 - s2 Set difference
s += e Add the element 'e' to set 's'
(same as the current "add s[e]")
s -= e Remove the 'e' element from 's', if present
(same as the current "delete s[e]")
s1 += s2 Same as "s1 = s1 + s2"
s1 -= s2 Same as "s1 = s1 - s2"
v += e Append the element 'e' to the vector 'v'
v += s Append the elements of 's' to the vector 'v',
with the order not being defined
s += v Add the elements of 'v' to 's'
s -= v Remove the elements of 'v' from 's', if present
These strike me as pretty straightforward, but please chime in if you
More information about the bro-dev