Announcement

Collapse
No announcement yet.

Associative Container in C++ Simplified

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Associative Container in C++ Simplified

    Introduction
    A container is an instantiated object, which has a list (array) as its fundamental feature. Unlike an array list, a container can grow or shrink in size (length). Different containers have different properties and methods. There are two types of container classes, called Sequences and Associative Containers. In this article, I introduce you to a tutorial series on C++ Associative Containers. I have written a different series for Containers Sequence, which I suggest you read before reading this one.

    Difference between Container Sequence and Associative Container
    The main difference between a Containers Sequence and an Associative Container is that a container sequence (vector) uses an index to access the element value, while the associative container (Map) uses a key (text) to access the element value.

    Limitations of the Array
    Imagine that you want to delete the element of a C++ array. That is not possible. You can set the value of a C++ array to NULL, but you cannot delete the element. Imagine that, you want to add an element (with value) to the top of the array. That is not possible. Imagine that you want to add an element (with value) to the bottom of an array. That is not possible with the C++ array. Those and other requirements are needed in modern programs.

    Solution to the limitations of the C++ Array
    Because of the limitations above, C++ came up with the sequences and associative containers. There are different forms of the associative container. One of them called, the Map will solve the above problems and more. Each associative container has its advantages and disadvantages.

    C++ is a complete language. Nothing is really left out. If you have studied a language like JavaScript, you would have noticed that its array is actually an object, which solves the above problems with methods. The C++ array is not an object in the strict sense of the word. However, in C++, the associative containers are objects. C++ is an old language and so it approached this problem from an original point of view. In my opinion, the authors (inventors) of some of the new languages got their inspiration from C++. Then they came up with compromises. They cane up with arrays that are objects, which will do some of the things that C++ containers do, but not all. In fact, JavaScript in particular does not have any equivalent to the associative container. Let me point out here that JavaScript was not written for the same purpose as C++; maybe that is why it is not as powerful.

    C++ has stood the test of time and it is competing fiercely with the new languages. So, I strongly advise you to study associative container.

    The tutorial series has been written in a step-by-step fashion. The code samples are well formatted with good indentation, making readability very easy. There are no missing special characters, as you would find in other sites. The links to the different parts of the series are easily accessible. Click the following link to start the series:

    **LINK REMOVED**
    Chrys
    Last edited by DPS Computing; 29-01-2012, 22:42. Reason: Possible spam - many messages with numerous links pasted in. Possible copy/paste
Working...
X