c++ using list class:: insert()


 
Thread Tools Search this Thread
Top Forums Programming c++ using list class:: insert()
# 1  
Old 01-12-2008
c++ using list class:: insert()

hello,
I am new to STL in c++ and using list class.
I had a application in which I have to insert object of a class into a list at particular position......
So first of all I had to call function through which I will take a position where i had to insert in a list then increment iterator to that position and insert at that location ..
I had used it like this:::::::::
void Data::addPacketFromSerial(char *rawData)
{
int psn; //where to add in the list//
list <Packet>::iterator Iter;
Iter=packetArr.begin();
Packet objPacket(rawData); //creating object of class packet and passing rawData to it's constructor//
objPacket.parseRawData(); //calling parseRawData to parse the packet//
psn=objPacket.getPsn(); //get the psn from packet class
psn--;
while(psn--)
{
Iter++;
}
packetArr.insert(Iter,objPacket); //insert at particular position

}

but its not doing it correctly????????/
please guide me as soon as possible.....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C++ : Base class member function not accessible from derived class

Hello All, I am a learner in C++. I was testing my inheritance knowledge with following piece of code. #include <iostream> using namespace std; class base { public : void display() { cout << "In base display()" << endl; } void display(int k) {... (2 Replies)
Discussion started by: anand.shah
2 Replies

2. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

3. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

4. UNIX for Dummies Questions & Answers

insert string at end of line if it found from list

Hi all, can some one help me out file 1 i have 06/01 3:14 d378299 06/01 8:10 d642036 06/01 10:51 d600441 06/01 10:52 d600441 06/01 11:11 d607339 06/01 11:49 d398706 something like this and in file named list i have ( there is space btwn 06/01 and 11:49 and d398706) d607339... (5 Replies)
Discussion started by: zozoo
5 Replies

5. Programming

static use for class inside the same class c++

Hi, I believe the next code is wrong: class Egg { Egg e; int i; Egg(int ii=0) : i(ii) {} }; because you would end up with an endless definition (memory allocation) of Egg objects, thus int i. Ok, so God Eckel proposes for a singleton: class Egg { static Egg e; int... (5 Replies)
Discussion started by: xavipoes
5 Replies

6. Shell Programming and Scripting

Match and insert in a sorted list

I have a sorted list (python) and I want to insert a string if it matches the pattern in list. Example : Sorted List Above list is in sorted order. I need to insert a name in sorted order and also if the name already exist then it should be inserted before the existing... (1 Reply)
Discussion started by: pratapsingh
1 Replies

7. Shell Programming and Scripting

Parsing fields from class list files to use output with newusers command

Hello I am trying to develop a shell script that takes a text file such as this... E-mail@ Soc.Sec.No. *--------Name-----------* Class *School.Curriculum.Major.* Campus.Phone JCC2380 XXX-XX-XXXX CAREY, JULIE C JR-II BISS CPSC BS INFO TECH 412/779-9445 JAC1936 XXX-XX-XXXX... (7 Replies)
Discussion started by: crimputt
7 Replies

8. Programming

C++ class definition with a member of the same class

Hi, i have a question about C++. Is it possible to declare a class with a member ot the same class? For example, a linked list or i want to convert this C code to C++ class (Elemento) typedef struct elemento { char name; char value; List<struct elemento> ltElementos; ... (7 Replies)
Discussion started by: pogdorica
7 Replies

9. UNIX for Dummies Questions & Answers

car class (not school class)

im just trying to have some fun and kill some time writing a c++ program that has a person type in a car make and model then gives them a year and a price. or something like that. i always have problems getting it goin but once the ball is rolling im usually pretty good. anyone wanna help me out? ... (1 Reply)
Discussion started by: rickym2626
1 Replies

10. Shell Programming and Scripting

How list of files apart from *.class files in certain folder

Hi Friends How to list of all files in a particular directory structure, with out listing a particular file extn. I mean to say in a folder structure I have many files ..I want to list them with out *.class files. Please help Thanks Joy (3 Replies)
Discussion started by: itsjoy2u
3 Replies
Login or Register to Ask a Question
std::__profile::list< _Tp, _Allocator >(3cxx)							     std::__profile::list< _Tp, _Allocator >(3cxx)

NAME
std::__profile::list< _Tp, _Allocator > - SYNOPSIS
Inherits list< _Tp, _Allocator >. Public Types typedef _Allocator allocator_type typedef __iterator_tracker < typename _Base::const_iterator, list > const_iterator" typedef _Base::const_pointer const_pointer typedef _Base::const_reference const_reference typedef std::reverse_iterator < const_iterator > const_reverse_iterator" typedef _Base::difference_type difference_type typedef __iterator_tracker < typename _Base::iterator, list > iterator" typedef _Base::pointer pointer typedef _Base::reference reference typedef std::reverse_iterator < iterator > reverse_iterator" typedef _Base::size_type size_type typedef _Tp value_type Public Member Functions list (const _Allocator &__a=_Allocator()) list (size_type __n) list (size_type __n, const _Tp &__value, const _Allocator &__a=_Allocator()) template<class _InputIterator > list (_InputIterator __first, _InputIterator __last, const _Allocator &__a=_Allocator()) list (const list &__x) list (const _Base &__x) list (list &&__x) list (initializer_list< value_type > __l, const allocator_type &__a=allocator_type()) _Base & _M_base () const _Base & _M_base () const void _M_profile_find () const void _M_profile_iterate (int __rewind=0) const void assign (initializer_list< value_type > __l) template<class _InputIterator > void assign (_InputIterator __first, _InputIterator __last) void assign (size_type __n, const _Tp &__t) reference back () const_reference back () const iterator begin () const_iterator begin () const const_iterator cbegin () const const_iterator cend () const void clear () const_reverse_iterator crbegin () const const_reverse_iterator crend () const template<typename... _Args> iterator emplace (iterator __position, _Args &&...__args) iterator end () const_iterator end () const iterator erase (iterator __position) iterator erase (iterator __position, iterator __last) reference front () const_reference front () const iterator insert (iterator __position, const _Tp &__x) iterator insert (iterator __position, _Tp &&__x) void insert (iterator __position, initializer_list< value_type > __l) void insert (iterator __position, size_type __n, const _Tp &__x) template<class _InputIterator > void insert (iterator __position, _InputIterator __first, _InputIterator __last) void merge (list &&__x) void merge (list &__x) template<class _Compare > void merge (list &&__x, _Compare __comp) template<typename _Compare > void merge (list &__x, _Compare __comp) list & operator= (const list &__x) list & operator= (list &&__x) list & operator= (initializer_list< value_type > __l) void pop_back () void pop_front () void push_front (const value_type &__x) reverse_iterator rbegin () const_reverse_iterator rbegin () const void remove (const _Tp &__value) template<class _Predicate > void remove_if (_Predicate __pred) reverse_iterator rend () const_reverse_iterator rend () const void resize (size_type __sz) void resize (size_type __sz, const _Tp &__c) void sort () template<typename _StrictWeakOrdering > void sort (_StrictWeakOrdering __pred) void splice (iterator __position, list &&__x) void splice (iterator __position, list &__x) void splice (iterator __position, list &__x, iterator __i) void splice (iterator __position, list &&__x, iterator __i) void splice (iterator __position, list &&__x, iterator __first, iterator __last) void splice (iterator __position, list &__x, iterator __first, iterator __last) void swap (list &__x) void unique () template<class _BinaryPredicate > void unique (_BinaryPredicate __binary_pred) Detailed Description template<typename _Tp, typename _Allocator = std::allocator<_Tp>>class std::__profile::list< _Tp, _Allocator > List wrapper with performance instrumentation. Definition at line 42 of file profile/list. Author Generated automatically by Doxygen for libstdc++ from the source code. libstdc++ Tue Nov 27 2012 std::__profile::list< _Tp, _Allocator >(3cxx)