You Are Here:

Community: Wiki

This page was last modified 13:39, 31 December 2007.

Two Dimensional TInt Array in Symbian

From Forum Nokia Wiki

The implementation below shows the creation to two dimensional integer array in symbian. The diagrammatic structure of implementation is given below for clear explanation.


Header File

#ifndef __TWODIMENSIONAL_H__
#define __TWODIMENSIONAL_H__
 
#include <e32std.h>
 
typedef RArray<TInt> RIntegerArray;
 
class R2DIntArray: public RPointerArray <RIntegerArray>
{
public:
    ~R2DIntArray();
    void ResetAndDestroy();
    inline TInt& At(TInt a1, TInt a2) { return (*((*this)[a1]))[a2]; }
	TInt Find(TInt aInteger);
	void Add(TInt aInteger);
 
	void AppendLast(TInt aPosition, TInt aValue);
	
};
#endif


Functions Implementation

// destructor
R2DIntArray::~R2DIntArray()
	{
	ResetAndDestroy();
	};
     
void R2DIntArray::ResetAndDestroy()
	{
	for (TInt i=0; i<Count(); i++) 
 
	{
 
		(*this)[i]->Reset();
 
	}
	RPointerArray<RIntegerArray>::ResetAndDestroy();
	};
 
 
 
// Finding the particular  integer value
 
TInt R2DIntArray::Find(TInt aInteger)
	{
	for (TInt i=0; i<Count(); i++)
		if (aInteger == (*((*this)[i]))[0])
			return i;
	return KErrNotFound;
	}
 
 
// adding the entry
void R2DIntArray::Add(TInt aInteger)
	{
	Append(new RIntegerArray);
	(*this)[Count() - 1]->Append(aInteger);
	}
 
// Appending the entry
 
void R2DIntArray::AppendLast(TInt aPosition, TInt aValue)
	{
	(*this)[aPosition]->Append(aValue);
	}



Two Dimensional Array Usage

R2DIntArray 2DArray;
2DArray.Reset();
2DArray.At(j,0)
2DArray.At(j,1)
2DArray.Count()
 
TInt j= 0 ; // value less than count of array.
TInt word = 25 // Any integer value.
 
RPointerArray<R2DIntArray> 2DPtrArray;
2DPtrArray.Append(new R2DIntArray);
2DPtrArray[0]->At(j,1); // refer to diagram  above for clear understanting 
TInt retWord = 2DPtrArray[0]->Find(word);
if(retWord != KErrNotFound)
{
   // you got the  index of the  searched word
}



  • RPointerArray<R2DIntArray> 2DPtrArray

( j ) -> ( 0 )( 1 )

[ 0 ] -> [ 0 ][20]

[ 1 ] -> [ 1 ][25]

[ 2 ] -> [ 2 ][35]

[ 3 ] -> [ 3 ][45]


  • R2DIntArray 2DArray


( 0 )( 1 )

[ 0 ][20]

[ 1 ][25]

[ 2 ][35]

[ 3 ][45]

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditFurlTechnocratiMagnoliaTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fMMPE5ffileX qdcZpublisherQUxhttpE3aE2fE2fswE2enokiaE2ecomE2fidE2fc764fd1cE2d8b06E2d499aE2d9a6aE2d17c3903d5a65E2fforumE5fnokiaE5fcrawlerE5fagentX qdcZtitleQSxMMPE20fileE20E2dE20ForumE20NokiaE20WikiX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfnTypeZCommunityContentQ qdcZtypeQUqfnTypeZE52esourceQ qdcZtypeQUqfnTypeZWebpageQ qdcZtypeQUqfnTypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qrssZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qfnZdistributionQUxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2fX qfnZtypeQUqfnTypeZCommunityContentQ qfnZtypeQUqfnTypeZE52esourceQ qfnZtypeQUqfnTypeZWebpageQ qfnZtypeQUqfnTypeZWikiContentQ qfnZupdatedQDx2008E2d10E2d02X qfnZuserE5ftagQSxfileX qfnZuserE5ftagQSxlibpathX qfnZuserE5ftagQSxmmpX qfnZuserE5ftagQSxresourceX qmarsZdescriptionQSxEa0E20WikiE20javaE20symbianE5fosE20s60E20maemoE20cE2bE2bE20WikiE20HomeE20WikiE20HelpE20OverviewE20GlossaryE20CreateE20PageE20ProposeE20anE20ArticleE20SpotlightE20TopicE20E2dE20WE52TE20WidgetsE20ProgrammingE20E4canguageE20E2dE20SymbianE20CE2bE2bE20E2dE20OpenE20CE2fCE2bE2bE20E2dE20JavaE20E2dE20FlashE20E4citeE20E2dE20PythonE20WebE20TechnologiesE20E2dE20WE52TE20WidgetsE20E2dE20WidSetsE20ToolsE20andE20SE44KE20CodeE20E45E78amplesE20KnowledgeE20BaseE20TechnologyE20AreasE20SoftwareE20PlatformsE20E44evelopmentE20ProcessE20E3fE3fWikiE20ChineseE20E3fE3fE3fWikiE20JapaneseE20PortugueseE2fBrazilianE20E52ussianE20WhatE20linksE20hereE20UploadE20fileE20SpecialE20pagesE20PrintableE20versionE44ownloadE20asE20PE44FE20GoE20ToE20E2eE2eE2eX qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfnTypeZCommunityContentQ qrdfZtypeQUqfnTypeZE52esourceQ qrdfZtypeQUqfnTypeZWebpageQ qrdfZtypeQUqfnTypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ