comp.lang.java.misc
  Home FAQ Contact Sign in
comp.lang.java.misc only
 
Advanced search
September 2008
motuwethfrsasuw
1234567 36
891011121314 37
15161718192021 38
22232425262728 39
2930      40
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.java.misc Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Generic generics help         


Author: wizard of oz
Date: Aug 28, 2008 22:11

I'm trying to write a data class using generics. This class is a Sparse
Matrix meaning that it can have many dimensions but not many entries (e.g. a
100 by 100 matrix, but there might only be 10 entries in the matrix).

I intend to use LinkedLists or Trees to manage the row and column keys and
probably a hash Map to manage the cells - but that's not important right
now.

My first step is that in my add method, I need to ensure that my row and
column keys are in my list. I would like to use one common routine for this.
The problem is I can't figure out the right generics syntax.

Here is what I started with:

public class SparseMatrix {

private TreeSet rowHeaders = new TreeSet ();
private TreeSet colHeaders = new TreeSet ();

public void add (R rowKey, C colKey, E element) {

ensureExists (rowHeaders, rowKey);
ensureExists (colHeaders, colKey);
}
Show full article (2.07Kb)
4 Comments
  'JXX] Get-Rich-Quick Cons BEWARE 'JXX]e)         


Author: Tisdale
Date: Jul 6, 2008 12:29

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

%%`+HjPHq;`.3#c1
no comments
  goHIi Rich or Stupid? goHIi]`         


Author: Barajas
Date: Jul 4, 2008 12:29

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

^^%%MN'DjI3d[jU0
no comments
  \x64J Rich or Stupid? \x64J o         


Author: izzard
Date: Jul 3, 2008 08:32

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

($a/Ns`,&'+FV>/
no comments
  vxU"4 Get-Rich-Quick Cons BEWARE vxU"4%%@         


Author: Torres
Date: Jul 3, 2008 01:44

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

M:WiVrRqm,[MPZ%%
no comments
  +XDD' Rich or Stupid? +XDD'4!         


Author: Kolar
Date: Jul 2, 2008 12:10

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

.w>>K8/EHFl0]@i
no comments
  V_CnR Get-Rich-Quick Cons BEWARE V_CnRvK         


Author: Miller
Date: Jul 2, 2008 05:13

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

HMuKM]hJ4x\Wpi9
no comments
  :^R`D Rich or Stupid? :^R`D"]         


Author: BLAZON
Date: Jul 1, 2008 22:18

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

<`>[UH
no comments
  [fev^ Get-Rich-Quick Cons BEWARE [fev^l         


Author: gonzales jr
Date: Jul 1, 2008 15:27

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

:/V$-H!alKlWY"2
no comments
  /IJ7C Get-Rich-Quick Cons BEWARE /IJ7CqV         


Author: rogers
Date: Jul 1, 2008 10:22

Must Read Book:

"Will The Next Liar Please Stand Up"

http://www.SoupNaziSecrets.com/ng2.html

R.R!9C*Yp=y_#,R
no comments
1 2 3 4 5 6 7