Why do these have such differing syntaxes? I understand that internally vectors are really much more similar to tables than sets, but in usage they're more equivalent to an ordered set than a table (in my mind at least). If we add FIFO-type operations to vectors so that they're easier to work with, they would feel even more like ordered sets. For example, using a totally made up code snippet...
Yeah, I also discovered that vectors are kinda limited in their
functionality. I think it would be great to have two different data
types in Bro. Possibly both supporting the same.
* array or vector (pretty much like the current vector type):
+ O(1) random element access
+ O(1) (armotized) adding to / removing from *end*
+ O(n) adding to / removing from *beginning*
+ grows (shrinks?) dynamically.
* queue, deque (for FIFOs, stacks, etc)
+ O(n) random element access
+ O(1) adding/removing from *either end*
Don't really like this syntax but also don't see another more
intuitive operator. Could we just add more built-ins for vector
operations like these? (e.g., vector_dequeue(v)). As usual,
type-safety would be a problem though.
IIRC, there's a #define that decides whether it's 0 or 1. (And yes, 0
based seems great). IIRC, 0 might be used as a special value in C++ code
but I'm not sure....
Right, technically the change is trivial, I was mainly looking for a
consensus. Seem we have one.
Well, depends on how you define consensus. I prefer indexing to start
with 1. I think use of 0-basing is a holdover from C's too-low-level model
equating arrays with pointers.
But given I'm the lone holdout, and vectors aren't something we've used
much, I'm not going to fight hard. However, I can picture an attribute
&base=1 or whatever to re-base particular vectors.