What is an unlimited array?

What is an unlimited array and is there a difference between an unlimited array and a dynamically allocated array? What are the common operations associated with an unlimited array? (for example, we have pop and click for stack data structure)

+4
source share
4 answers

Unlimited arrays can (and usually) be statically allocated.

The main problem when implementing an unlimited array is to provide a dynamic array, such as freedom, to determine the size of the array at runtime without penalties for the performance of memory allocation at runtime.

-

. limit size, , . , size, , size. , , limit . limit , .

, size limit , .

( ) :

  • ( )
  • ( , )
  • ( )

, ( ), , :

  • add_to_end()
  • delete_from_end()

.

, Insert_in_middle() Delete_in_middle(), , .

. .

. , , . C++ std::vector, , . >

+2

. , , , , . .

sArray = Array[2..10] Of Integer
dArray = Array[x..y] Of Integer

void DoSomethingToArray(Array Of Integer : myArray)
{
   for(int i = myArray.LowerBound; i <= myArray.UpperBound; i++)
   {
      // twiddle with it.
   }
} 

sArray dArray , .

: While! Stack.Empty, List.Count > 0, Enumerator, Sizeof (myArray)/SizeOf (myArrayType) - . , , , , , .

. , , , , , , .

+2

, . . / , , /pop enqueue/dequeue / . , .

int userInput = 0;
 Array dynamic_arr = new Array[userinput];//example of dynamic array
List<string> unbounded_arr = new List<string>(); // example of unbounded array
+1

A - , . , . , .

, .

, . . / .

, TheCodeArtist:

struct ubarray {
    int limit; /* limit > 0 */
    int size; /* 0 <= size && size <= limit */
    elem[] A; /* \length(A) == limit */
};

, ( ) :

elem[] A; /* \length(A) == limit */
+1

Source: https://habr.com/ru/post/1524924/


All Articles