🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › Map.html
Map (Java Platform SE 8 )
3 days ago - An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.
Discussions

java - What is the class of Map - Stack Overflow
I have to pass to a constructor the class of Map . if i pass Map.class only, I have an error. So I would like to know what's the class of Map ? p... More on stackoverflow.com
🌐 stackoverflow.com
parameterized - Java map, key = class, value = instance of that class - Stack Overflow
I'm not sure what I want to do is possible, but if it is, I want to find out how. Basically, I want to create a Map where the key is a class (java.lang.Class), and value for that entry is an instan... More on stackoverflow.com
🌐 stackoverflow.com
Policy-map and class-map
Class maps are used to build a policy map. The class-map typically contains some set of rules of what you're trying to match (e.g. match traffic against this access-list, match traffic with a certain DSCP marking, etc.). The policy-map references the class-maps and then adds some action, like setting a bandwidth limit. The class-maps can be re-used in different policy-maps, policy-maps can also be nested/contain other policy-maps. class-map match-any VOICE match ip dscp ef match ip dscp af31 match access-group name VOICE-NETWORKS class-map match-any ROUTING match ip dscp cs6 Here I have two class maps. These are both "match-any", meaning if any of the rules defined are matched, then the class-map as a whole is matched. If you're familiar with boolean logic, this would be an OR statement. You could also do a "match-all", where all the match statements have to be true for the class-map to be a match. "match-all" would be a boolean AND. policy-map WAN-QoS-Policy class VOICE priority percent 25 class ROUTING bandwidth percent 3 Here I have a policy-map, which is calling the previous class-maps for VOICE and ROUTING. In this policy map, I'm doing some QOS stuff, where traffic matching the VOICE class map would get a certain QOS policy applied (priority percent 25), and traffic matching the ROUTING class map has a different QOS policy applied (bandwidth percent 3). Because its modular, I could create a different policy-map and keep using the same class-maps, if I wanted to keep using those matching patterns but apply a different action to them (maybe I have two WAN circuits with different bandwidths so I need to change my QOS policies. policy-map WAN-QoS-Policy-HighBandwidth class VOICE priority percent 5 class ROUTING bandwidth percent 1 policy-map WAN-QoS-Policy-ShittyCircuit class VOICE priority percent 50 class ROUTING bandwidth percent 10 None of this does anything without these policies actually being applied somewhere, so you still need to figure out where you want these policies to take effect interface gig0/0 service-policy output WAN-QoS-Policy-HighBandwidth interface gig0/1 service-policy output WAN-QoS-Policy-ShittyCircuit As for your SIP questions, if it's a router there should be a SIP-UA section, there may be a destination server defined there. You may also have a SIP destination defined under dial-peers, if you have any dial-peers defined. There's also some config at the top with voice classes. Look for any commands that mention something like binding or source, that would be telling the router to use a specific interface/IP when handling voice traffic. The syntax is different if its SIP vs. h323 or MGCP, but they all involve terms like source interface or bind More on reddit.com
🌐 r/ccna
7
5
July 22, 2019
Python, is map a class or function - Stack Overflow
It's used as a function, but why: >>> help(map) Help on class map in module builtins: class map(object) | map(func, *iterables) --> map object | | Make an iterator that computes ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Scala Documentation
docs.scala-lang.org › overviews › scala-book › map-class.html
The Map Class | Scala Book | Scala Documentation
The Map class documentation describes a Map as an iterable sequence that consists of pairs of keys and values.
🌐
Microsoft Learn
learn.microsoft.com › en-us › cpp › standard-library › map-class
map Class | Microsoft Learn
API reference for the C++ Standard Template Library (STL) `map` class, which is used for the storage and retrieval of data from a collection in which each element is a pair that has both a data value and a sort key.
🌐
ArcGIS Pro
pro.arcgis.com › en › pro-app › 3.4 › sdk › api-reference › topic11850.html
Map Class
October 26, 2024 - Represents the primary object used for the organization of geographic data.
🌐
CRS Info Solutions
crsinfosolutions.com › home › what is a map class in salesforce apex? with examples
What is a Map class in Salesforce Apex? with examples
Salesforce Training
The Map class is a collection type that stores unique keys paired with values. It is used to quickly retrieve, update, or delete data based on a unique identifier, making data handling more efficient and faster than using lists, especially with large data sets. I have enrolled for Salesforce Admin and development online course at CRS info solutions. It’s really the best training i have ever taken and syllabus is highly professional
Rating: 5 ​
Find elsewhere
🌐
Utah
myclassmap.utah.edu
My Class Map - The University of Utah
University of Utah Interactive Campus Parking Map.
🌐
ArcGIS Pro
pro.arcgis.com › en › pro-app › 3.4 › arcpy › mapping › map-class.htm
Map—ArcGIS Pro | Documentation
It is important to uniquely name each map so a specific map can be easily referenced with the wildcard parameter that uses the name property. A map can also be accessed from a MapFrame object using the map property. The createMap method on the ArcGISProject class allows you to create a map ...
🌐
Flutter
api.flutter.dev › flutter › dart-core › Map-class.html
Map class - dart:core library - Dart API
API docs for the Map class from the dart:core library, for the Dart programming language.
🌐
GeeksforGeeks
geeksforgeeks.org › java › map-interface-in-java
Map Interface in Java - GeeksforGeeks
It is part of the Java Collections Framework, and its key implementation classes include HashMap, LinkedHashMap, TreeMap, and Hashtable. HashMap: Stores key-value pairs using hashing for fast access, insertion, and deletion.
Published   January 7, 2026
Top answer
1 of 6
19

Java's type system is simply not strong enough to enforce the type constraint you're describing directly, and you'll need to do some unsafe casts to make this work -- or wrap the Map in some other API that enforces the type safety. Guava's ClassToInstanceMap does just that for exactly this use case, providing an externally safe API that imposes additional restrictions on the Map interface to make it work. (Disclosure: I contribute to Guava.)

The only time this can cause a memory leak is if there's some classes you're using here that would not be retained for the life of the application. This isn't a concern for many users, especially if you're writing a "server side" application that isn't as concerned about unloading unused classes.

2 of 6
18

What you are using is a heterogeneous container. These can be made typesafe by using type tokens (as you already do) and Class.cast() with the correct application logic: So there is an unchecked suppressWarning within Class.cast(), but the application logic guarantees correctness.

I advise you read Josh Bloch's Effective Java Item 29: Consider typesafe heterogeneous containers. His example is:

// Typesafe heterogeneous container pattern - implementation
public class Favorites {
  private Map<Class<?>, Object> favorites =
    new HashMap<Class<?>, Object>();

  public <T> void putFavorite(Class<T> type, T instance) {
    if (type == null)
      throw new NullPointerException("Type is null");
    favorites.put(type, instance);
  }

  public <T> T getFavorite(Class<T> type) {
    return type.cast(favorites.get(type));
  }
}

I only see a possibility for memory leakage if you hold arbitrarily many different types you actually no longer need.

🌐
Reddit
reddit.com › r/ccna › policy-map and class-map
r/ccna on Reddit: Policy-map and class-map
July 22, 2019 -

I'm trying to decipher a router config and I am trying to figure out how these 2 command work together. I've been reading about it but I need someone to explain it to me like I'm 5.

Also, how would I go about determining which of these VLANs is identified as a voice VLAN? There is no obvious voice configurations it looks like all the voice data is being handled by the SIP trunk but I can't figure out which IP is the SIP trunk...

anyway..

Top answer
1 of 1
5
Class maps are used to build a policy map. The class-map typically contains some set of rules of what you're trying to match (e.g. match traffic against this access-list, match traffic with a certain DSCP marking, etc.). The policy-map references the class-maps and then adds some action, like setting a bandwidth limit. The class-maps can be re-used in different policy-maps, policy-maps can also be nested/contain other policy-maps. class-map match-any VOICE match ip dscp ef match ip dscp af31 match access-group name VOICE-NETWORKS class-map match-any ROUTING match ip dscp cs6 Here I have two class maps. These are both "match-any", meaning if any of the rules defined are matched, then the class-map as a whole is matched. If you're familiar with boolean logic, this would be an OR statement. You could also do a "match-all", where all the match statements have to be true for the class-map to be a match. "match-all" would be a boolean AND. policy-map WAN-QoS-Policy class VOICE priority percent 25 class ROUTING bandwidth percent 3 Here I have a policy-map, which is calling the previous class-maps for VOICE and ROUTING. In this policy map, I'm doing some QOS stuff, where traffic matching the VOICE class map would get a certain QOS policy applied (priority percent 25), and traffic matching the ROUTING class map has a different QOS policy applied (bandwidth percent 3). Because its modular, I could create a different policy-map and keep using the same class-maps, if I wanted to keep using those matching patterns but apply a different action to them (maybe I have two WAN circuits with different bandwidths so I need to change my QOS policies. policy-map WAN-QoS-Policy-HighBandwidth class VOICE priority percent 5 class ROUTING bandwidth percent 1 policy-map WAN-QoS-Policy-ShittyCircuit class VOICE priority percent 50 class ROUTING bandwidth percent 10 None of this does anything without these policies actually being applied somewhere, so you still need to figure out where you want these policies to take effect interface gig0/0 service-policy output WAN-QoS-Policy-HighBandwidth interface gig0/1 service-policy output WAN-QoS-Policy-ShittyCircuit As for your SIP questions, if it's a router there should be a SIP-UA section, there may be a destination server defined there. You may also have a SIP destination defined under dial-peers, if you have any dial-peers defined. There's also some config at the top with voice classes. Look for any commands that mention something like binding or source, that would be telling the router to use a specific interface/IP when handling voice traffic. The syntax is different if its SIP vs. h323 or MGCP, but they all involve terms like source interface or bind
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › util › Map.html
Map (Java Platform SE 7 )
An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › Map.html
Map (Java SE 21 & JDK 21)
January 20, 2026 - An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value. This interface takes the place of the Dictionary class, which was a totally abstract class rather than an interface.
🌐
Stanford
web.stanford.edu › dept › cs_edu › resources › cslib_docs › Map
class Map< KeyType , ValueType >
This class maintains an association between keys and values. The types used for keys and values are specified using templates, which makes it possible to use this structure with any data type. The map uses a binary search tree (BST) structure internally.
Top answer
1 of 1
3

The misunderstanding is due to poor documentation that doesn't catch a major change in specs, or due to the CPython implementation which dare to write a class for what is listed as a built-in function in the specs.

In Python 2, it is a function that returns a list. In the online documentation of Python 2, it is listed under Built-in Functions. The first line of help(map) on CPython 2.7.10 reads

Help on built-in function map in module builtin

correctly calling it a function.

In Python 3, they changed the specs that it returns an iterator instead of a list. As @RafaelC noted, it has an advantage of lazy loading. Althiugh it is still under "Built-n Functions", the CPython implementation decided to make it a class. This change is reflected in help(map), which you have seen and quoted in the question.

What you are doing when you call map() in CPython 3 is, you are creating an object of class map with the parameters you throw. This is clearly shown when you try to print what map() returns.

CPython 2.7.10:

>>> map(int, "12345")
[1, 2, 3, 4, 5]

CPython 3.7.2:

>>> map(int, "12345")
<map object at 0x1023454e0>

So you are clearly creating an object of class map, which makes what you've seen in help(map) sound very fine.

So it seems that, to the CPython core developers, a class can be a "function" with some definiton of a "function". This is clearly misleading. Anyway, it implements the necessary methods that enables it to be used as an iterator. (as the docs says, if you ignore that it's listed under builtin functions.)


It's used as a function

That's because the syntax of calling a function and fetching its return value is identical to creating a class object (by calling its initializer) and fetching the object.

For example, using a function my_function() as in return_value = my_function() is syntactically no different from creating a class object of my_class() as in my_object = my_class(). When you call map() in CPython 3, you are creating an object of class map. But you would write the same even if map were a function. That's why you're confused.


So in short,

  1. map was a function in CPython 2, but is a class in CPython 3. That is clear from help(map) on both versions, and that's what the CPython implementation does.

  2. The documentation keeps it under "Built-in functions" while CPython implementation finds liberty to write a class for it, causing confusion.

  3. It's a shame that the two aren't clearly distinguished in the docs.