T
T
tschin2015-07-02 11:52:27
Qt
tschin, 2015-07-02 11:52:27

How to store a large number of elements in an array?

Tell me how to store data, the amount of which exceeds the maximum value of the int type? Don't use index...

Answer the question

In order to leave comments, you need to log in

6 answer(s)
C
Cyril, 2015-07-02
@endemic

If I'm not mistaken, size_t is used as an array index, which corresponds to the maximum memory size for a processor with a given bit depth. That is, the situation you describe cannot happen in principle.
en.cppreference.com/w/cpp/types/size_t

D
dordzhiev, 2015-07-02
@dordzhiev

Instead of a thousand words.

E
Evhen, 2015-07-02
@EugeneP2

For the index, use the long type,
and for storage, use several arrays of the maximum size and, depending on the value of the index, calculate the real index of the desired array

V
Vitaly Pukhov, 2015-07-02
@Neuroware

with respect to any language, you can build a structure in which there will be an array of references to other arrays and the GetValue function with any type as a parameter, then determine in which array this element lies, for example, as a result of dividing the parameter by the maximum number of elements in the array, the remainder of this division will be the number of the element in the array. But in fact, the need for such a large array indicates the incorrectness of the application architecture, the task itself needs to be reconsidered.

T
tschin, 2015-07-02
@tschin

Thanks for answers!

A
AxisPod, 2015-07-03
@AxisPod

How are you going to work with such data sizes at all? Here it is already necessary to dig in the direction of displaying files in memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question