Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

When I write high-level documentation about what an algorithm does, I use the term "array" to refer to the data structure on which the algorithm operates even though the actual data structure is an std::vector. I feel that using the term "vector" in this context does not (to me) best convey the meaning I'm after which is "a sequence of elements with constant-time random access" or perhaps more generally "a dynamic array". Is there a convention or common documentation standard for this distinction of similar terms?

share|improve this question
This is all confusing. C++'s map is not your LISP's Python's map. At the end of the day these are just words. I, for instance, really want to call some data structure a "ladder" ... just because. –  Job Jun 9 '11 at 23:14
The C++ standard uses the term Sequence to generically describe the sort of data structure you're talking about. A vector is both a Sequence and a RandomAccessContainer. –  Charles Salvia Jun 9 '11 at 23:45
I think I'd use "random access sequence." –  James McNellis Jun 9 '11 at 23:58
Does it have to be sequential? Except where necessary, I would use the term "container" or "collection" and let the implementations worry about the best technique for storing it. –  Caleb Huitt - cjhuitt Jun 10 '11 at 2:23

4 Answers 4

up vote 2 down vote accepted

I don't know of any standard nomenclature, but like the OP, I prefer using "array" or "dynamic array" for something that has constant-time random access, without specifying the mechanism.

Even though STL uses the term "vector", I come from a mathematics/chemistry background, and do a lot of 2D/3D graphics. In those fields, when you say "vector" in a generic way, it has its linear algebra meaning: a point in an N-dimensional vector space. When I use "vector" in the STL sense, I'm always referring to that specific STL template container.

To me, "list" when applied to containers implies "linked list", which doesn't have constant-time random access. Like Neil Butterworth, I rarely use std::list.

share|improve this answer

First, know your audience!

I understand from where are you coming from, but If you are writing to C++ people, Use vector. A C++ programmer would know what you mean by vector. Within the C++ context, If you are calling a vector an array, it might be confusing to some folks. IF you still want to use the name "Array", then I will suggest to make a note that you make no distinction between static and dynamic array.

If you are talking to non-technical people, then use the word list or something easier than convey the message (I would still try to define vector because they might get technical later on.)

Good luck!

share|improve this answer
If you are writing to any decent programmer, Use array. –  Thomas Eding May 8 '13 at 20:06

We all have our little coding idiosyncrasies, but... come on man!

You're using a vector, why would you call it an array? They're two different things.

An "array" is not a universally known concept. That is, you can't walk up to a random person, ask them what an array is, and expect them to know. So how does that particular word convey the concept of "a collection of elements with constant-time random access" better than "vector"?

Have more faith in your colleagues. Anyone looking over your code who knows what an array is should know what a vector is. And if they don't, you have bigger problems.

share|improve this answer
I'm not sure why but I thought of "array" as a more universally known term, but you might be right on this. Thanks +1 –  Lex Jun 10 '11 at 0:35
Using vector to people who don't know C++ (or other languages that use this unfortunate terminology) for "a collection of elements with constant-time random access" is a joke. Vectors are canonically mathematical objects, often of a fixed dimension. Use array or list or sequence. Of course, this doesn't apply if you are actually coding in such a language. –  Thomas Eding May 8 '13 at 20:11

Interesting. I always use the term "list" as it is (almost) the most degenerate form of a collection, and so the most general. I almost never use std::list in my actual C++ code. however. As a real example from my own code:

 typedef std::vector <unsigned int> FieldList;
share|improve this answer
Why you don't use FieldVector? Keep in mind that the first thing that most people will not think is that you call "vector" as "list" or "string" as "int". –  Armando Jun 9 '11 at 23:56
@Armando Because I might want to turn it into a set? Or a deque? It's just a bunch of stuff, so I use the most general term - a list. –  nbt Jun 10 '11 at 0:00
@Neil, Keep in mind that List is a well defined data structure. I know where you are coming from and is a good idea to do typedef rather than hardcore the template type. I used typedef for STL containers as well. I think Scott Meyers used the word "Container" for generic data structure. –  Armando Jun 10 '11 at 0:06
Isn't the term "range" used a lot when talking about generic algorithms? Anything with a beginning and an end... is that too general for the OP's situation? –  Kerrek SB Jun 12 '11 at 9:52
@Kerrek Range is used to refer to that - a range inside a container, which might be over the entire contents, or might not. What's being asked about here is a name for the container itself. –  nbt Jun 12 '11 at 9:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.