本文整理汇总了C#中System.Collections.SortedList类的典型用法代码示例。如果您正苦于以下问题:C# SortedList类的具体用法?C# SortedList怎么用?C# SortedList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SortedList类属于System.Collections命名空间,在下文中一共展示了SortedList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MatchSubstring
private static Match[] MatchSubstring(string i_source, string i_matchPattern, bool i_uniqueMatch)
{
//<note> use RegexOptions.Multiline, otherwise it will treat the whole thing as 1 string
Regex regex = new Regex(i_matchPattern, RegexOptions.Multiline);
MatchCollection matchCollection = regex.Matches(i_source);
Match[] result;
if (!i_uniqueMatch)
{
result = new Match[matchCollection.Count];
matchCollection.CopyTo(result, 0);
}
else
{
//<note> cannot use HashSet<Match> because each Match object is unique, even though they may have same value (string). Can use HashSet<string>
//SortedList is more like sorted Dictionary<key, value>
SortedList uniqueMatchCollection = new SortedList();
foreach(Match match in matchCollection)
{
if (!uniqueMatchCollection.ContainsKey(match.Value))
{
uniqueMatchCollection.Add(match.Value, match);
}
}
result = new Match[uniqueMatchCollection.Count];
uniqueMatchCollection.Values.CopyTo(result, 0); //<note> cannot use uniqueMatchCollection.CopyTo(...) since SortedList member is not type-match with destination array member
}
Console.WriteLine("Found {0} matches", result.Length);
return result;
}
示例2: Scene
//SpriteFont debugfont;
public Scene(Game game)
: base(game)
{
World = new World(new Vector2(0, 18));
PhysicsDebug = new DebugViewXNA(World);
InputManager = new InputManager(Game);
Transitioner = new Transitioner(Game, this);
#if !FINAL_RELEASE
SelectionManager = new SelectionManager(Game, this);
#endif
SceneLoader = new SceneLoader(Game);
Camera = new Camera(Game, this);
GarbageElements = new SortedList<Element>();
RespawnElements = new SortedList<Element>();
Elements = new SortedList<Element>();
PhysicsDebug.Enabled = false;
SelectionManager.ShowEmblems = false;
Kinect.ColorStream.Enable();
Kinect.DepthStream.Enable();
Kinect.SkeletonStream.Enable();
Kinect.Start();
//SelectionManager.ShowForm = false;
}
示例3: ComputeTrendTest
public void ComputeTrendTest(SortedList<int, double> years, int currentYear)
{
var map = new ExtractValuesForIndicatorsMapper();
var data = new SortedList<int, double>();
double[] inflationVal ={100.764370305146,104.476042578907,
164.776810573524,343.810676313218,626.718592068498,672.180651051974,
90.0966050749321,131.327020980362,342.955110191569,3079.8097030531,
2313.96466339751,171.671696468307,24.8999485988254,10.6114940961306,
4.17734724367,3.37611684980121,0.155695900742245,0.527258257063252
,0.920336467095566,-1.16689546970002,-0.935939411978723,-1.06663550777849,
25.8684978656633,13.4428492915644,4.41571792341912,9.63939954620811,
10.901124534884,
8.83141298885049};
int length = inflationVal.Count();
int year = 2007;
for (int i = length - 1; i >= 0; i--)
{
data.Add(year, inflationVal[i]);
year--;
}
Assert.IsTrue( map.ComputeTrend(data, 1998)<1);
Assert.IsTrue( map.ComputeTrend(data, 1999)<1);
Assert.IsTrue( map.ComputeTrend(data, 2000)<1);
Assert.IsTrue( map.ComputeTrend(data, 2001)<1);
Assert.IsTrue(map.ComputeTrend(data, 2002)>1);
Assert.IsTrue(map.ComputeTrend(data, 2003)>1);
}
示例4: RowRecordsAggregate
private RowRecordsAggregate(SharedValueManager svm)
{
_rowRecords = new SortedList();
_valuesAgg = new ValueRecordsAggregate();
_unknownRecords = new ArrayList();
_sharedValueManager = svm;
}
示例5: TestConstructor3
public void TestConstructor3 ()
{
Hashtable d = new Hashtable ();
d.Add ("one", "Mircosoft");
d.Add ("two", "will");
d.Add ("three", "rule");
d.Add ("four", "the world");
SortedList temp1 = new SortedList (d);
Assert.IsNotNull (temp1, "#A1");
Assert.AreEqual (4, temp1.Capacity, "#A2");
Assert.AreEqual (4, temp1.Count, "#A3");
try {
new SortedList ((Hashtable) null);
Assert.Fail ("#B");
} catch (ArgumentNullException) {
}
try {
d = new Hashtable ();
d.Add ("one", "Mircosoft");
d.Add ("two", "will");
d.Add ("three", "rule");
d.Add ("four", "the world");
d.Add (7987, "lkj");
new SortedList (d);
Assert.Fail ("#C");
} catch (InvalidOperationException) {
}
}
示例6: ThemeProvider
public ThemeProvider(IDesignerHost host, string name, string themeDefinition, string[] cssFiles, string themePath)
{
this._themeName = name;
this._themePath = themePath;
this._cssFiles = cssFiles;
this._host = host;
ControlBuilder builder = DesignTimeTemplateParser.ParseTheme(host, themeDefinition, themePath);
this._contentHashCode = themeDefinition.GetHashCode();
ArrayList subBuilders = builder.SubBuilders;
this._skinBuilders = new Hashtable();
for (int i = 0; i < subBuilders.Count; i++)
{
ControlBuilder builder2 = subBuilders[i] as ControlBuilder;
if (builder2 != null)
{
IDictionary dictionary = this._skinBuilders[builder2.ControlType] as IDictionary;
if (dictionary == null)
{
dictionary = new SortedList(StringComparer.OrdinalIgnoreCase);
this._skinBuilders[builder2.ControlType] = dictionary;
}
Control control = builder2.BuildObject() as Control;
if (control != null)
{
dictionary[control.SkinID] = builder2;
}
}
}
}
示例7: EventStreamSlice
private EventStreamSlice()
{
m_streamPosition = EventStreamPosition.Start;
m_events = new SortedList<StreamVersion, JournaledEvent>(0);
m_endOfStream = true;
m_currentSlicePosition = EventStreamPosition.Start;
}
示例8: Button
public Button()
{
this.m_bNoScalingOnSetRect = true;
Name = "Button";
this.MouseActive = true;
m_plStateSprites = new SortedList();
Frame spFrame = new Frame();
spFrame.Parent = this;
spFrame.Member = new MemberSpriteBitmap("Button2Up");
spFrame.Ink = RasterOps.ROPs.BgTransparent;
spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
spFrame.Rect = new ERectangleF(0,0,50,50);
m_plStateSprites.Add(Sprite.MouseEventType.Leave, (Sprite)spFrame);
spFrame = new Frame();
spFrame.Parent = this;
spFrame.Member = new MemberSpriteBitmap("Button2Down");
spFrame.Ink = RasterOps.ROPs.BgTransparent;
spFrame.Member.ColorKey = Color.FromArgb(0,0,0);
spFrame.Rect = new ERectangleF(0,0,50,50);
m_plStateSprites.Add(Sprite.MouseEventType.Enter, (Sprite)spFrame);
for (int i = 0; i < m_plStateSprites.Count; i++)
{
((Sprite)m_plStateSprites.GetByIndex(i)).Visible = false;
}
((Sprite)m_plStateSprites[MouseEventType.Leave]).Visible = true;
}
示例9: btnSave_Click
void btnSave_Click(object sender, EventArgs e)
{
SortedList sl = new SortedList();
Qry = "delete from Unit_master where UnitGroupName='" + cboUnitType.Text + "'";
sl.Add(sl.Count + 1, Qry);
for (int i = 0; i < dgvInfo.Rows.Count - 1; i++)
{
Qry = "INSERT INTO [dbo].[Unit_Master] " +
" ([UnitGroupName]" +
" ,[UnitID]" +
" ,[UnitName]" +
" ,[RelativeFactor]" +
" ,[IsBaseUOM]" +
" ,[AddedBy]" +
" ,[DateAdded])" +
" VALUES " +
" ('" + cboUnitType.Text + "'," +
"'" + dgvInfo.Rows[i].Cells[0].Value.ToString() + "'," +
"'" + dgvInfo.Rows[i].Cells[1].Value.ToString() + "'," +
"" + dgvInfo.Rows[i].Cells[2].Value.ToString() + "," +
"'" + Convert.ToBoolean(dgvInfo.Rows[i].Cells[3].Value) + "'," +
"'" + LoginSession.UserID + "',getdate())";
sl.Add(sl.Count + 1, Qry);
}
DbUtility.ExecuteQuery(sl, "");
MessageBox.Show("Saved");
}
示例10: Type2CIDFont
/// <summary>
/// Class constructor.
/// </summary>
/// <param name="properties"></param>
public Type2CIDFont(FontProperties properties) {
this.properties = properties;
this.baseFontName = properties.FaceName.Replace(" ", "-");
this.usedGlyphs = new SortedList();
ObtainFontMetrics();
}
示例11: TemplateCollection
public TemplateCollection()
{
eX4XcIhHpDXt70u2x3N.k8isAcYzkUOGF();
// ISSUE: explicit constructor call
base.\u002Ector();
this.aJ8duHpkdC = new SortedList();
}
示例12: ExecuteSclrBySP
public string ExecuteSclrBySP(string sp, SortedList sl)
{
string err = string.Empty;
string returnSclr = "-1";
SqlConnection con = new SqlConnection(DbConnStr);
SqlCommand cmd = new SqlCommand(sp, con);
cmd.CommandType = CommandType.StoredProcedure;
foreach (DictionaryEntry entry in sl)
{
cmd.Parameters.Add(new SqlParameter(entry.Key.ToString(), entry.Value));
}
try
{
con.Open();
returnSclr = Convert.ToString(cmd.ExecuteScalar());
}
catch (Exception ex)
{
err = ex.Message;
}
finally
{
con.Close();
}
return returnSclr;
}
示例13: ServerDBQuery
public DataSet ServerDBQuery(string strProcName, DataSet dsIN)
{
try
{
SortedList SDList = new SortedList();
if (dsIN.Tables.Count > 0 && dsIN.Tables[0].Rows.Count > 0)
{
DataRow dR = dsIN.Tables[0].Rows[0];
for (int i = 0; i < dsIN.Tables[0].Columns.Count; i++)
{
SDList[dsIN.Tables[0].Columns[i].ColumnName] = dR[i];
}
}
return WSBDB.proGetDS(SDList, strProcName);
}
catch (Exception Ex)
{
#region 错误日志
string strSDList = "";
if (dsIN.Tables.Count > 0 && dsIN.Tables[0].Rows.Count > 0)
{
DataRow dR = dsIN.Tables[0].Rows[0];
for (int i = 0; i < dsIN.Tables[0].Columns.Count; i++)
{
strSDList += dsIN.Tables[0].Columns[i].ColumnName + ":" + dR[i] + "$";
}
}
string strErrEx = "出现未知错误,请联系系统管理员查询日志,方法" + strProcName + "参数:" + strSDList + "错误ID:" + Guid.NewGuid().ToString();
WSBDB.txtSaveErro(strErrEx + ":" + Ex.ToString());
#endregion
return null;
}
}
示例14: FindSubstrings
public static Match[] FindSubstrings(string source, string matchPattern, bool findAllUnique)
{
SortedList uniqueMatches = new SortedList();
Match[] retArray = null;
Regex RE = new Regex(matchPattern, RegexOptions.Multiline);
MatchCollection theMatches = RE.Matches(source);
if (findAllUnique)
{
for (int counter = 0; counter < theMatches.Count; counter++)
{
if (!uniqueMatches.ContainsKey(theMatches[counter].Value))
{
uniqueMatches.Add(theMatches[counter].Value,
theMatches[counter]);
}
}
retArray = new Match[uniqueMatches.Count];
uniqueMatches.Values.CopyTo(retArray, 0);
}
else
{
retArray = new Match[theMatches.Count];
theMatches.CopyTo(retArray, 0);
}
return (retArray);
}
示例15: TargetSelectorCallback
protected void TargetSelectorCallback(Address start, SortedList score_table, Address current) {
Assert.IsTrue(score_table.Count > 0);
if (current == null) {
Address min_target = (Address) score_table.GetByIndex(0);
Assert.AreEqual(_addr_list[_idx++], min_target);
}
}