C++有vertor,java有HashMap,C语言想使用则需要自行封装,不同的类型还需要再封装,特别麻烦。

看看Go语言的map的使用方法:var member map[string]int,创建一个key是string,值是int类型的map。

此时的member还不能使用,必须使用 member = make(map[string]int)进行初始化,或者直接使用: member := make(map[string]int)。

package main

import (
"fmt"
) func main() {
member := make(map[string]int) member["age"] = 10
member["level"] = 1 fmt.Println(member)
}

或者在定义的时候直接初始化:

package main

import (
"fmt"
) func main() {
member := map[string]int {
"fix" : 3,
} member["age"] = 10
member["level"] = 1 fmt.Println(member)
}

【访问元素】

member["age"] = 10

【删除元素】

delete(member, "age")

【获取长度】

len(member)

【判断相等】

if map1 == map2 {

}

用起来还是很爽的map,不需要考虑内存问题。

9. maps的更多相关文章

  1. 检索Google Maps地图位置(小训练)

    名称:检索地图位置 内容:地图初期显示和检索显示 功能:根据条件检索地图的经度与纬度 1.在这之前我们需要创建一个表(Accoun__c),添加一个重要的字段地理位置情報,它会默认的给你两个字段经度和 ...

  2. [Erlang 0121] 当我们谈论Erlang Maps时,我们谈论什么 Part 3

    Erlang/OTP 17.0 has been released  http://www.erlang.org/download/otp_src_17.0.readme     Erlang/OTP ...

  3. [Erlang 0117] 当我们谈论Erlang Maps时,我们谈论什么 Part 2

    声明:本文讨论的Erlang Maps是基于17.0-rc2,时间2014-3-4.后续Maps可能会出现语法或函数API上的有所调整,特此说明. 前情提要: [Erlang 0116] 当我们谈论E ...

  4. [Erlang 0116] 当我们谈论Erlang Maps时,我们谈论什么 Part 1

         Erlang 增加 Maps数据类型并不是很突然,因为这个提议已经进行了2~3年之久,只不过Joe Armstrong老爷子最近一篇文章Big changes to Erlang掀起不小了风 ...

  5. The Practical Guide to Empathy Maps: 10-Minute User Personas

    That’s where the empathy map comes in. When created correctly, empathy maps serve as the perfect lea ...

  6. Windows 10 新特性 -- Bing Maps 3D地图开发入门(一)

    本文主要内容是讲述如何创建基于 Windows Universal App 的Windows 10 3D地图应用,涉及的Windows 10新特性包括 Bing Maps 控件.Compiled da ...

  7. Google Maps API V3 之绘图库 信息窗口

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  8. Google Maps API V3 之 图层

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  9. Google Maps API V3 之 路线服务

    Google官方教程: Google 地图 API V3 使用入门 Google 地图 API V3 针对移动设备进行开发 Google 地图 API V3 之事件 Google 地图 API V3 ...

  10. java.lang.IllegalArgumentException: Result Maps collection does not contain value for java.lang.Integer

    今天做springmvc+mybatis+spring的项目的时候发现了一个异常.如下: org.apache.ibatis.builder.IncompleteElementException: C ...

随机推荐

  1. Windows硬链接 软链接 符号链接 快捷方式

    http://blog.nsfocus.net/shortcuthard-linkjunction-pointsymbolic-link/ Windows支持4种”链接”机制,分别是shortcut. ...

  2. Linux安装/升级pip

    Linux安装/升级pip 1.执行脚本 # wget https://bootstrap.pypa.io/get-pip.py # 如果没有 wget,先安装 wget # yum -y insta ...

  3. day1--一个简单的登录接口

    _usrename = "Yvan"_password = "abc123"count=0while count <3:    username = in ...

  4. IC5141安装备忘

    X Error of failed request:  BadName (named color or font does not exist)   Major opcode of failed re ...

  5. [EasyUI]确认删除

    //删除方法 function del() { var obj = getSelected(); if (obj) { $.messager.confirm('确认', '确定要删除:' + obj. ...

  6. VB 调用 webservice 出现:WSDLReader:Loading of the WSDL file failed HRESULT=0×80040154: 没有注册类别 解决方案

    有些 VB 程序在调用  webservice  的时候出现“WSDLReader:Loading of the WSDL file failed HRESULT=0×80040154: 没有注册类别 ...

  7. jenkins部署前后端分离的vue项目

    1 General Name: 变量名. 类似给分支起一个名字的意思, 可随意取 Description: 描述, 非必填 Parameter Type: 选择 Branch or Tag Defau ...

  8. vue3.0中如何使用ueditor

    1.在官网下载一个ueditor版本[https://ueditor.baidu.com/website/download.html],解压后放到public文件下的static文件中重命名为Edit ...

  9. C#压缩文件,C#压缩文件夹,C#获取文件

    using System; using System.Data; using System.Configuration; using System.Collections.Generic; using ...

  10. 2018-2019-2 20165205 网络攻防Exp3免杀原理与实践

    2018-2019-2 20165205 网络攻防Exp3免杀原理与实践 一.实践内容 1.1正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil-evasion,加壳工具,使用 ...