Operation on array - c program, C/C++ Programming

Operation on array:

void Array::add( Object& toAdd )

{

    lastElementIndex++;

    while( ptrAt( lastElementIndex ) != ZERO &&

           lastElementIndex <= upperbound

         )

        lastElementIndex++;

 

    if( lastElementIndex > upperbound )

        reallocate( lastElementIndex - lowerbound + 1 );

 

    setData( lastElementIndex, &toAdd );

    itemsInContainer++;

    CHECK( itemsInContainer > 0 );

}

 

void Array::addAt( Object& toAdd, int atIndex )

{

    PRECONDITION( atIndex >= lowerbound );

    if( atIndex > upperbound )

        reallocate( atIndex - lowerbound + 1 );

 

    if( ptrAt( atIndex ) != ZERO )

        {

        delete ptrAt( atIndex );

        }

 

    setData( atIndex, &toAdd );

}

Posted Date: 10/18/2012 6:12:11 AM | Location : United States







Related Discussions:- Operation on array - c program, Assignment Help, Ask Question on Operation on array - c program, Get Answer, Expert's Help, Operation on array - c program Discussions

Write discussion on Operation on array - c program
Your posts are moderated
Related Questions
Aim: To implement a program to create, update & display account & admin record of person using display account & admin records of person using virtual base class.. Code:

Question 1 What are the different steps in executing a C program? Explain Question 2 What are the commonly used input/output functions in C? How are they accessed?

A more advanced data type is the structure; here we can define a template as a collection of different variables e.g.     struct birthdate   {     int month;     int day;

Assume that a Binary Search Tree is constructed by repeatedly inserting exact values in to the tree. Argue that the number of nodes examined in searching for a value in the tree is

C o n t r o l S t r u c t u r e s I t i s o f t h r e e t y p e s: 1 .    S e qu e n c e s t r u c t u r e 2 .

please help me get all the inbuilt functions in c++

Use of random function: int main(void) {    int i,j;         for(j=0;j       {      // randomize();       for(i=0;i                  printf("%d\n", ran

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Hiding overloaded functions We cannot overload a base class function by redefining it in a derived class with a dissimilar argument list. Consider examples to see if similar fu