POV-Ray : Newsgroups : povray.off-topic : A question about Java generics (not a flame) : A question about Java generics (not a flame) Server Time
7 Sep 2024 13:22:56 EDT (-0400)
  A question about Java generics (not a flame)  
From: Warp
Date: 9 May 2008 05:34:12
Message: <48241a93@news.povray.org>
Yes, I know it would be better to ask this in a Java forum, but I'm just
too lazy to dig one up (as well as not too eager to show my ignorance in
a random forum ;) ). Given the amount of programmers here, I'm sure at
least someone knows the answer to this.

  In C++, if you have a very complicated template type, such as for example:

std::map<std::string, std::vector<std::vector<std::string> > >

it would be quite laborious to have to write that type every single time
when you need it. The solution to this is to create a type alias:

typedef std::map<std::string, std::vector<std::vector<std::string> > >
    TheMap;

  Now it's much shorter to use that type. For example:

TheMap m;
for(TheMap::iterator iter = m.begin(); iter != m.end(); ++iter)
    ...

  Java supports generics, which are instantiated with a syntax very similar
to this. However, Java does not support type aliases.

  Is there a way in Java to shorten those long type names?

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.