[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Swarm-Support] What is the best way to model "lists" of integersin
From: |
Paul Johnson |
Subject: |
Re: [Swarm-Support] What is the best way to model "lists" of integersin Obj-C? |
Date: |
Tue, 06 Feb 2007 16:48:11 -0600 |
User-agent: |
Thunderbird 1.5.0.9 (X11/20061219) |
Luke Premo wrote:
Hello,
I would like to use "lists" of (negative and positive) integers in my
Obj-C model (Mac OSX, Swarm 2.2) to represent simple genomes. So far,
I've used the List object to do this, but i get some strange results
(i.e., getCount returns 10 but when I print out the contents of the
"haplotype" I don't always get 10 integers...sometimes i get none) not
to mention the following compiler warning: Hominin.m:38: warning:
passing argument 1 of 'addLast:' makes pointer from integer without a
cast. I get the feeling List is only reliable for objects and not
integers, is this true? And if so, what would be a better choice for
me given that i want to be able to add/remove integers with offsets
and use the addLast/First and removeLast/First commands when modeling
recombination between two "lists" of integers? Should I switch to
Arrays, Collections, or Strings to do this?
All containers accept objects, not integers. Create an Integer class,
and then set values into those objects, and add them to lists.
I'm attaching a class I've used in the past for integers.
If my hunch is wrong, and Lists can deal with integers just fine, then
how come I can't get all 10 of the integers to print out for me using
a while loop on an index of the haplotype List and the printf
function? I'm stumped.
I'm sure this is a simple problem, but I've been unsuccessful in
finding a definitive answer after searching for the last couple of
hours. I would greatly appreciate any suggestions. Thank you very
much for you time,
Luke Premo
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Support mailing list
address@hidden
http://www.swarm.org/mailman/listinfo/support
--
Paul E. Johnson email: address@hidden
Dept. of Political Science http://pj.freefaculty.org
1541 Lilac Lane, Rm 504
University of Kansas Office: (785) 864-9086
Lawrence, Kansas 66044-3177 FAX: (785) 864-5700
#import <objectbase/SwarmObject.h>
//A small wrapper class to hold integers so we can insert them into
//swarm lists
#define SWARMINTEGER(value) \
[[[SwarmInteger createBegin: [self getZone]] setVal: value] createEnd]
@interface SwarmInteger: SwarmObject
{
int value;
}
- setVal: (int)theValue;
- (int)getVal;
@end
#import "SwarmInteger.h"
@implementation SwarmInteger
{
int value;
}
- setVal: (int)theValue
{
value = theValue;
return self;
}
- (int)getVal
{
return value;
}
@end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [Swarm-Support] What is the best way to model "lists" of integersin Obj-C?,
Paul Johnson <=