Skip to content

can't write a constructor for KeyValuePair #31

@twiglet

Description

@twiglet

Yeah, I have a Dictionary<KVP<T,K>,V> I'm populating, so I have to create the KVPs.

I'll make a new type in c# and change the translation file. Shouldn't hurt anything if that's just a sub-class of KVP on c# side, right?

Since you're scanning everything for context, might it be possible eventually to support different translation templates to be applied based on usage? So. if "new" is applied to this type anywhere, it's a KVPsupport, otherwise it's an entry. Naturally all references would have to agree.

This particular case isn't a big deal, but I wonder if there are other C# / java differences that could help with?

-Ben

On Thu, Feb 2, 2012 at 4:15 AM, Kevin Glynn kevin.glynn@scorm.com wrote:

The Object.Equals imp is good.

Unfortunately the KeyValuePair change is going to break stuff that I want to keep, e.g. at the moment:

static IDictionary<int, IDictionary<String, int>>
Rename(IDictionary<Set, int> renamer,
IDictionary<Set, IDictionary<String, Set>> trans) {
IDictionary<int, IDictionary<String, int>> newtrans =
new Dictionary<int, IDictionary<String, int>>();
foreach (KeyValuePair<Set, IDictionary<String, Set>> entry
in trans) {
Set k = entry.Key;
IDictionary<String, int> newktrans = new Dictionary<String, int>();
foreach (KeyValuePair<String, Set> tr in entry.Value)
newktrans.Add(tr.Key, renamer[tr.Value]);
newtrans.Add(renamer[k], newktrans);
}
return newtrans;
}

translates to

static Map<Integer,Map<String,Integer>> rename(Map<Set,Integer> renamer, Map<Set,Map<String,Set>> trans) throws Exception {
Map<Integer,Map<String,Integer>> newtrans = new HashMap<Integer,Map<String,Integer>>();
for (Entry<Set,Map<String,Set>> entry : trans.entrySet())
{
Set k = entry.getKey();
Map<String,Integer> newktrans = new HashMap<String,Integer>();
for (Entry<String,Set> tr : entry.getValue().entrySet())
newktrans.put(tr.getKey(), renamer.get(tr.getValue()));
newtrans.put(renamer.get(k), newktrans);
}
return newtrans;
}

but if we translate KVP to some new KVPSupport type then of course the built in Java types can't produce one of those.

What is the use case? I suppose you just want to create a pair? If so I think I might need you to create a pair type in your C#.

cheers

k

On 02 Feb 2012, at 00:36, Ben Clark wrote:

Please look this commit over when you get a chance, and see if you anticipate any trouble.

Or tweak to conform to your conventions.

https://github.com/RusticiSoftware/CS2JLibrary/commit/f116896fd821b08afae2696b82cd83a7f3b499f5

Ben Clark | http://scorm.com/tincan | +1 615.538.8550 | @ProjectTinCan

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions