<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indirect Addressing | Student Projects</title>
	<atom:link href="https://studentprojects.in/tag/indirect-addressing/feed/" rel="self" type="application/rss+xml" />
	<link>https://studentprojects.in</link>
	<description>Microcontroller projects, Circuit Diagrams, Project Ideas</description>
	<lastBuildDate>Thu, 27 Jan 2011 10:52:11 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.7</generator>
	<item>
		<title>Program to represent Indirect Addressing of Linear List using Templates</title>
		<link>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/program-to-represent-indirect-addressing-of-linear-list-using-templates/</link>
					<comments>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/program-to-represent-indirect-addressing-of-linear-list-using-templates/#respond</comments>
		
		<dc:creator><![CDATA[Editorial Team]]></dc:creator>
		<pubDate>Sat, 29 Jan 2011 10:49:31 +0000</pubDate>
				<category><![CDATA[Data structure]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[linear list]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[Indirect Addressing]]></category>
		<category><![CDATA[indirect list]]></category>
		<guid isPermaLink="false">http://studentprojects.in/?p=1218</guid>

					<description><![CDATA[<p>IndirectList(int MaxLinearSize=10);<br />
~IndirectList();//destructor<br />
int IsEmpty()const{return length==0;}<br />
int Length()const{return length;}<br />
int Find(int k,T&#038;x)const;<br />
int Search(const T&#038;x)const;<br />
void Delete(int k,T&#038;x);<br />
void Insert(int k,const T&#038;x);<br />
void Output()const;</p>
<p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/program-to-represent-indirect-addressing-of-linear-list-using-templates/">Program to represent Indirect Addressing of Linear List using Templates</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></description>
										<content:encoded><![CDATA[<pre lang="cpp">
#include<iostream.h>
#include<constream.h>
template<class T>
class IndirectList
{
	private:
		int length;
		int MaxSize;
		T**table; 
	public:
		IndirectList(int MaxLinearSize=10);  	
		~IndirectList();//destructor
		int IsEmpty()const{return length==0;}
		int Length()const{return length;}
		int Find(int k,T&x)const;
		int Search(const T&x)const;
		void Delete(int k,T&x);

		void Insert(int k,const T&x);

		void Output()const;
};
	template<class T>
IndirectList<T>::IndirectList(int MaxListSize)
{
	MaxSize=MaxListSize;
	table=new T*[MaxSize];
	length=0;
}
	template<class T>
IndirectList<T>::~IndirectList()
{
	for(int i=0;i<length;i++)
		delete table[i];
	delete[]table;
}
template<class T>
int IndirectList<T>::Find(int k,T&x)const
{
	if(k<1||k>length)
		return 0; //no kth element
	if(x==*table[k-1])
		return 1;
	else
		return 0;
}
template<class T>
int IndirectList<T>::Search(const T&x)const
{
	for(int i=0;i<length;i++)
		if(*table[i]==x)
			return ++i;
	return 0;
}
	template<class T>
void IndirectList<T>::Delete(int k,T&x)
{
	if(Find(k,x))
	{
		for(int i=k;i<length;i++)
			table[i-1]=table[i];
		length--;
	}
	else
		cout<<"out of bounds\n";
}
	template<class T>
void IndirectList<T>::Insert(int k,const T&x)
{
	if(k<0||k>length)
		cout<<"out of bounds\n";
	if(length==MaxSize)
		cout<<"no memory\n";
	for(int i=length-1;i>=k;i--)
		table[i+1]=table[i];
	table[k]=new T;
	*table[k]=x;
	length++;
}
template<class T>
void IndirectList<T>::Output()const
{
	if(IsEmpty())
		cout<<"list is empty\n";
	else
		for(int i=0;i<length;i++)
			cout<<*table[i]<<"\t";
}
void menu()
{
	cout<<"\n MENU\n";
	cout<<"1.Length\n";
	cout<<"2.Find\n";
	cout<<"3.Search\n";
	cout<<"4.Delete\n";
	cout<<"5.Insert\n";
	cout<<"6.Output\n";
}
void main()
{
	int choice;
	int k,x,len,p;
	clrscr();
	IndirectList<int>obj;
	do
	{
		menu();
		cout<<"enter choice\n";
		cin>>choice;
		switch(choice)
		{
			case 1:
				len=obj.Length();
				if(len==0)
					cout<<"List is empty\n";
				else
					cout<<"length of Indirectlist is "<<len<<endl;
				break;
			case 2:
				cout<<"enter k,x(position and value)\n";
				cin>>k>>x;
				p=obj.Find(k,x);
				if(p==1)
					cout<<"found"<<endl;
				if(p==0)
					cout<<"not found"<<endl;
				break;
			case 3:
				cout<<"enter x(value)\n";
				cin>>x;
				p=obj.Search(x);
				if(p)
					cout<<"searching is sucessful and found at "<<p<<endl;
				else
					cout<<"searching not sucessful"<<endl;
				break;
			case 4:
				cout<<"enter k,x(position and value)\n";
				cin>>k>>x;
				obj.Delete(k,x);
				break;
			case 5:
				cout<<"enter k,x(index and value)\n";
				cin>>k>>x;
				obj.Insert(k,x);
				break;
			case 6:
				cout<<"elements in the list are:\n\n";
				obj.Output();
				break;
			default:
				cout<<"invalid choice\n";
		}
	}
	while(choice>=1&&choice<=6);
	getch();
}
</pre><p>The post <a href="https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/program-to-represent-indirect-addressing-of-linear-list-using-templates/">Program to represent Indirect Addressing of Linear List using Templates</a> first appeared on <a href="https://studentprojects.in">Student Projects</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://studentprojects.in/software-development/cpp/cpp-programs/cpp-data-structure/program-to-represent-indirect-addressing-of-linear-list-using-templates/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
