BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 12-07-2010, 05:29 AM   #1 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9650
PIN: N/A
Carrier: Developer
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default How to use Queue, Stack Data Structures?

Please Login to Remove!

Hi all,
You can tell me how to use Queue, Stack , Link Listed,... Data Structures in BlackBerry Project?
Thanks for any suggestion !
Offline  
Old 12-07-2010, 08:29 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: How to use Queue, Stack Data Structures?

My suggestion is to go get a book and learn programming.

This question is too broad for a real answer.
Offline  
Old 12-07-2010, 10:40 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2010
Model: 8530
PIN: N/A
Carrier: Sprint
Posts: 48
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: How to use Queue, Stack Data Structures?

You have to implement the code like this:

Code:
public class Queue {
	private Object[] mElements = new Object[] {};

	public void enqueue(Object element) {
		if (element != null) {
			Arrays.add(mElements, element);
		}
	}

	public Object dequeue() {
		Object result = null;
		if (mElements != null && mElements.length > 0) {
			result = mElements[0];
			Arrays.remove(mElements, result);
		}
		return result;
	}

	public Object peek() {
		if (mElements != null && size() > 0)
			return mElements[0];
		else
			return null;
	}

	public int size() {
		if (mElements.length > 0) {
			return mElements.length;
		} else {
			return 0;
		}
	}
}
Offline  
Old 12-08-2010, 08:29 PM   #4 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9650
PIN: N/A
Carrier: Developer
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: How to use Queue, Stack Data Structures?

Quote:
Originally Posted by romah View Post
You have to implement the code like this:

Code:
public class Queue {
	private Object[] mElements = new Object[] {};

	public void enqueue(Object element) {
		if (element != null) {
			Arrays.add(mElements, element);
		}
	}

	public Object dequeue() {
		Object result = null;
		if (mElements != null && mElements.length > 0) {
			result = mElements[0];
			Arrays.remove(mElements, result);
		}
		return result;
	}

	public Object peek() {
		if (mElements != null && size() > 0)
			return mElements[0];
		else
			return null;
	}

	public int size() {
		if (mElements.length > 0) {
			return mElements.length;
		} else {
			return 0;
		}
	}
}
I understand and i know how to implement those data structures. But i want to ask you how to setup BlackBerry Projects for it can use those data structures that is available in java. I have used Queue<integer> and i have added jre6 library into my project. It has complied without error but it can't package for run or debug. Thanks for your suggestion!

Last edited by levanphong7887 : 12-08-2010 at 08:30 PM.
Offline  
Old 12-08-2010, 10:59 PM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default Re: How to use Queue, Stack Data Structures?

You are trying to use Java SE classes in Java ME - this will not work.

You must a) use the collections that are available in the RIM API, and/or b) write your own Queue, Stack, etc.

Have you reviewed the RIM javadocs?
Offline  
Old 12-09-2010, 01:35 AM   #6 (permalink)
New Member
 
Join Date: Oct 2010
Model: 9650
PIN: N/A
Carrier: Developer
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Re: How to use Queue, Stack Data Structures?

Quote:
Originally Posted by Dougsg38p View Post
You are trying to use Java SE classes in Java ME - this will not work.

You must a) use the collections that are available in the RIM API, and/or b) write your own Queue, Stack, etc.

Have you reviewed the RIM javadocs?
I have read Development Guide documents on BlackBerry home page but I haven't found this part. Can you give me the document for this, thanks !
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: How to use Queue, Stack Data Structures?
Thread Thread Starter Forum Replies Last Post
Showing continous streamed data on screen and refreshing the screen accordingly hemant.bobade Developer Forum 0 05-19-2009 08:53 AM
Make web browser GPRS data appear as email on T-Mobile Unlimited International plan caffeamericano BlackBerry Network 1 12-31-2008 05:32 PM
How to wirelessly delete the calendar data on a BlackBerry smartphone hdawg BES Admin Corner 2 04-03-2008 01:56 PM
RIM CEO cautious about unlimited wireless data plans Sterling General BlackBerry Discussion 4 06-07-2006 08:49 AM
BB as a Modem - Data usage - costs and the BES Tolan General BlackBerry Discussion 5 02-26-2006 10:28 AM





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.