Click here to Skip to main content
15,900,973 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Multiple Desktop Pin
Super Lloyd30-Dec-21 17:00
Super Lloyd30-Dec-21 17:00 
GeneralRe: Multiple Desktop Pin
theoldfool31-Dec-21 0:43
professionaltheoldfool31-Dec-21 0:43 
RantMy brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 8:08
mvahoney the codewitch30-Dec-21 8:08 
RantRe: My brain hurts: overlapping range lists Pin
0x01AA30-Dec-21 8:19
mve0x01AA30-Dec-21 8:19 
GeneralRe: My brain hurts: overlapping range lists Pin
oofalladeez34330-Dec-21 8:33
professionaloofalladeez34330-Dec-21 8:33 
GeneralRe: My brain hurts: overlapping range lists Pin
ElectronProgrammer30-Dec-21 9:10
ElectronProgrammer30-Dec-21 9:10 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 9:34
mvahoney the codewitch30-Dec-21 9:34 
GeneralRe: My brain hurts: overlapping range lists Pin
ElectronProgrammer30-Dec-21 10:35
ElectronProgrammer30-Dec-21 10:35 
I do not know what is possible to do in C# but, when a default data structure does not directly implement everything I need, I always try to make my data storage classes independent of the underlying storage type (data structure) by using templates and abstract classes.

Let us say that I want to store ClassA instances ordered by something that is a combination of some of its fields. I would probably make it ClassAStorage implements ClassStorageBase<actualstorageclass> where ClassStorageBase<t> implements the methods I need to make ClassStorage easier to work with including some abstract methods that will depend on ClassAStorage to be implemented and will be used in other methods of ClassStorageBase.

This also helps reusing code for, say, a ClassB that can be easily implemented as a ClassBStorage implements ClassStorageBase<anotherstorageclass>.

Simple snippet using my custom list:
- My storage class
Java
public abstract class IndexedSet<TYPE_KEY extends Object,TYPE_DATA extends Object> {
	//this class implements the ArrayList<TYPE_DATA> interface but was omitted due to length

	private HashMap<TYPE_KEY,TYPE_DATA > cells;
}

- My ordered storage class
Java
public abstract class IndexedSequence<TYPE_KEY extends Object,TYPE_DATA extends Object> extends IndexedSet<TYPE_KEY,TYPE_DATA>{
	
	private ArrayList<TYPE_KEY> cellsOrder;

	public Entry<TYPE_KEY, TYPE_DATA> get(int pos) {
		TYPE_KEY k=cellsOrder.get(pos);
		return new Pair<TYPE_KEY, TYPE_DATA>(k,internal().get(k));
	}
}

- My base storage table (indexed rows that have indexed columns)
Java
public abstract class TableCore<TYPE_KEY extends Object,TYPE_DATA extends Object>{
	/**
	 * Method to get the TYPE_DATA key.
	 * Must be overridden by the class that implements a specific table.
	 * 
	 * @param r is the instance of TYPE_DATA
	 * @return the key of the given instance
	 */
	protected abstract TYPE_KEY getKey(TYPE_ROW r);
//the above method is used anywhere a key is needed in this class
}

- finally, my class
Java
public class TableBasic<TYPE_DATA extends Object> extends TableCore<Integer, TYPE_DATA>{
	
	@Override
	protected Integer getKey(TYPE_DATA r) {
		return r.hashCode();
	}
}

- and my other class
Java
public class Table extends TableCore<UUID, TYPE_DATA extends MyData>{
	
	@Override
	protected UUID getKey(TYPE_DATA r) {
		return r.id();
	}
}

And, yes, it is a lot of work.
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 11:18
mvahoney the codewitch30-Dec-21 11:18 
GeneralRe: My brain hurts: overlapping range lists Pin
Super Lloyd30-Dec-21 9:30
Super Lloyd30-Dec-21 9:30 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 9:32
mvahoney the codewitch30-Dec-21 9:32 
GeneralRe: My brain hurts: overlapping range lists Pin
Super Lloyd30-Dec-21 10:22
Super Lloyd30-Dec-21 10:22 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 11:17
mvahoney the codewitch30-Dec-21 11:17 
GeneralRe: My brain hurts: overlapping range lists Pin
Super Lloyd30-Dec-21 11:22
Super Lloyd30-Dec-21 11:22 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 11:32
mvahoney the codewitch30-Dec-21 11:32 
GeneralRe: My brain hurts: overlapping range lists Pin
Super Lloyd30-Dec-21 11:36
Super Lloyd30-Dec-21 11:36 
GeneralRe: My brain hurts: overlapping range lists Pin
Super Lloyd30-Dec-21 10:29
Super Lloyd30-Dec-21 10:29 
GeneralRe: My brain hurts: overlapping range lists Pin
ElectronProgrammer30-Dec-21 9:35
ElectronProgrammer30-Dec-21 9:35 
GeneralRe: My brain hurts: overlapping range lists Pin
Gerry Schmitz30-Dec-21 9:51
mveGerry Schmitz30-Dec-21 9:51 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 9:55
mvahoney the codewitch30-Dec-21 9:55 
GeneralRe: My brain hurts: overlapping range lists Pin
Gerry Schmitz30-Dec-21 10:05
mveGerry Schmitz30-Dec-21 10:05 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 11:14
mvahoney the codewitch30-Dec-21 11:14 
GeneralRe: My brain hurts: overlapping range lists Pin
0x01AA30-Dec-21 11:20
mve0x01AA30-Dec-21 11:20 
GeneralRe: My brain hurts: overlapping range lists Pin
honey the codewitch30-Dec-21 11:37
mvahoney the codewitch30-Dec-21 11:37 
GeneralRe: My brain hurts: overlapping range lists Pin
Gerry Schmitz30-Dec-21 19:06
mveGerry Schmitz30-Dec-21 19:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   497 votes