473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Remove pointer from list

Dear cpp-ians,

I am writing code for a image segmentation program. For this purpose I
want to make a list (or array) of all pixels and take a random pixel
out of the list. Once the pixel is handled, I want to remove it from
the list and take again a random pixel out of the new list (with the
previous pixel removed).

I have an image of 1450 x 1650 pixels. Every pixel is a pointer to a
structure:

struct group
{
float value; // the gray value of the original image
struct meta_group * group; // the image segment it belongs to
struct pixel * pixel_list; // the first pixel of a list of all pixels
of the image segment
struct pixel * edge_list; // the first pixel of a list of all border
pixels of the image segment
};

Now I want:

* to put all those pointers in a list
* take a random pointer out of the list and do some processing on it
* remove it from the list
* take a new random pointer from the list (with the previous pointer
removed).

Can anyone help me on how to program it? What function should I use to
remove the pointer from the list or array?

Thanx in advance!

Kind regards,
Stef

Jul 23 '05 #1
2 2512
koperenkogel wrote:

Dear cpp-ians,
* to put all those pointers in a list
* take a random pointer out of the list and do some processing on it
* remove it from the list
* take a new random pointer from the list (with the previous pointer
removed).

Can anyone help me on how to program it? What function should I use to
remove the pointer from the list or array?


put all pointers into a vector
now 'shuffle' that vector, bring it into a random order (there
is an STL algorithm to do that)
and work straight to the vector using a simple loop.

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 23 '05 #2
Ok, very nice idea and it works!

Thanx!

Stef

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Neil | last post by:
Hello, Is there a standard or recommended way of handling deletion and removal of objects in STL. I have loads of list of classes by pointer. e.g. If I have a list<int*>, how should I delete...
11
by: koperenkogel | last post by:
Dear cpp-ians, I am working with a vector of structures. vector <meta_segment> meta_segm (2421500); and the structure look like: struct meta_segment { float id; float num;
6
by: Arne Claus | last post by:
Hi If've just read, that remove() on a list does not actually remove the elements, but places them at the end of the list (according to TC++STL by Josuttis). It also says, that remove returns a...
7
by: Kieran Simkin | last post by:
Hi all, I'm having some trouble with a linked list function and was wondering if anyone could shed any light on it. Basically I have a singly-linked list which stores pid numbers of a process's...
0
by: aredo3604gif | last post by:
I have coded a serie of singly linked lists in ANSI C which I have to use. The lists are then stored in a serie of buckets with chained hash table technique. In the various lists there are nodes...
6
by: Jonathan | last post by:
Hi. I'm having trouble figuring out what I should be doing here. I'm trying to remove an object from a list. The function is: void Alive::FromRoom () { list<Alive>::iterator iter =...
4
by: eksamor | last post by:
I have a simple linked list: struct element { struct element *next; int start; }; struct list { struct element *head;
3
by: Andy | last post by:
Hello, I have the following situation: Thread A is allocating a dataset, doing some low-level calculations and storing a pointer to the dataset in a std::list via push_back. Thread B should...
4
by: tshad | last post by:
I have an ArrayList of thread pointers that I want delete from my list when the Thread in not alive and status is stopped. But I want to do it from the foreach loop I am looping through. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.