Well I figured out what the problem was, my adding after filling up the array was flawed
for(int x = 0; x<CompFiles.length; x++)
{
int stat = c.compareTo((Wrapper) CompFiles[x]);
if(stat > 0)
{
CompFiles[x]=c;
return;
}
}
Bascially say I have the 2nd largest, 3rd largest, and 4th largest filled up the array of 4. But I have 5 files. I find the 5th file, check the [0] of the array first, which would be the 2nd largest, and figure OH LOOK ITS LARGER and throw that out.
So I had to find the smallest in that array, adn then check to see if its bigger than the file I'm looking to add.
public void add(Comparable<Wrapper> c)
{
for(int x =0; x<CompFiles.length ; x++)
{
if(CompFiles[x] == null )
{
CompFiles[x] = c;
return;
}
}
int smallestFileIndex=0;
long smallestFileSize=((Wrapper)CompFiles[0]).getSize();
for(int x=0; x<CompFiles.length; x++)
{
if(((Wrapper)CompFiles[x]).getSize()<smallestFileSize)
smallestFileIndex=x;
}
if(((Wrapper)CompFiles[smallestFileIndex]).getSize()<((Wrapper) c).getSize())
CompFiles[smallestFileIndex]=c;
}
As you see, I just had to add a check thats it.