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
how to use nested loop of for in array

The concept of a string in C is difficult, because a string is a collection of characters stored in memory terminated by a NULL string i.e. \0. Let us consider the string Hello. Th

algorithm to find out all the factors of given positive integers

Described the difference among "new" and "operator new" ? A:"operator new" works such as malloc.

For the circuit shown in Figure, verify (a) the battery voltage V , (b) the total resistance of the circuit, and (c) the values of resistance of resistors R 1 , R 2 and

how to decode the numerals to string..

Purpose This assignment is an exercise in implementing the queue ADT using a singly-linked list. This assignment also introduces the concept of templates. Assignment Th

Binary logical bit-wise operators  There are three logical bit-wise operators :                   &             and                 |              or

what is c++ ?