我试图找到有关它的信息但失败了。
size()
或HashMap
中的HashSet
如何实施?它是如何工作的?是O(1)
还是O(n)
操作?
答案 0 :(得分:6)
需要size
次。 HashMap
有一个/**
* Returns the number of key-value mappings in this map.
*
* @return the number of key-value mappings in this map
*/
public int size() {
return size;
}
实例变量,在添加或删除条目时会被修改:
这是HashSet
实施:
size()
HashMap
调用了<%@ Control Language="C#" AutoEventWireup="true"
Inherits="CMSWebParts_General_ResetPassword"
CodeBehind="~/CMSWebParts/General/ResetPassword.ascx.cs" %>
<div id="reset-password-page" class="col-md-12">
<div class="col-md-3">
</div>
<div class="col-md-6">
<h1 style="color: white; margin-top: 0px;">Reset Password</h1>
<div style="margin-top: 30px; color: #eb770a!important; padding-left: 20px;" class="row">
<div class="form-group row">
<span style="color: red; position: relative; left: 12px;" id="validation"></span>
</div>
<div class="form-group row">
<asp:Label ID="lblPassword" runat="server" Text="Password:" CssClass="col-sm-3 control-label">Password:</asp:Label>
<div class="col-sm-9">
<asp:TextBox ID="txtPassword" runat="server" Text="" TextMode="Password" CssClass="form-control" ClientIDMode="Static" Monitor="Monitor" data-rel="password"></asp:TextBox>
</div>
</div>
<div class="form-group row">
<asp:Label ID="lblPassword2" runat="server" Text="Repeat Password:" CssClass="col-sm-3 control-label">Repeat Password:</asp:Label>
<div class="col-sm-9">
<asp:TextBox ID="txtPassword2" runat="server" Text="" TextMode="Password" CssClass="form-control" ClientIDMode="Static" Monitor="Monitor" data-rel="password"></asp:TextBox>
</div>
</div>
<div class="form-group row">
<div class="offset-sm-2 col-sm-10" id="reset">
<asp:Button ID="ResetBtn" runat="server" CssClass="btn caseFileButton" Text="Reset" CausesValidation="True" />
</div>
</div>
</div>
</div>
<div class="col-md-3"></div>
的{{1}}。