v0.0.1-Alpha (#42)
This commit is contained in:
parent
d30f93c454
commit
a36796c2c1
3552 changed files with 2476 additions and 15223 deletions
75
Projects/Server/KeywordList.cs
Normal file
75
Projects/Server/KeywordList.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/***************************************************************************
|
||||
* KeywordList.cs
|
||||
* -------------------
|
||||
* begin : May 1, 2002
|
||||
* copyright : (C) The RunUO Software Team
|
||||
* email : info@runuo.com
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
namespace Server
|
||||
{
|
||||
public class KeywordList
|
||||
{
|
||||
private static int[] m_EmptyInts = new int[0];
|
||||
private int[] m_Keywords;
|
||||
|
||||
public KeywordList()
|
||||
{
|
||||
m_Keywords = new int[8];
|
||||
Count = 0;
|
||||
}
|
||||
|
||||
public int Count{ get; private set; }
|
||||
|
||||
public bool Contains(int keyword)
|
||||
{
|
||||
bool contains = false;
|
||||
|
||||
for (int i = 0; !contains && i < Count; ++i)
|
||||
contains = keyword == m_Keywords[i];
|
||||
|
||||
return contains;
|
||||
}
|
||||
|
||||
public void Add(int keyword)
|
||||
{
|
||||
if (Count + 1 > m_Keywords.Length)
|
||||
{
|
||||
int[] old = m_Keywords;
|
||||
m_Keywords = new int[old.Length * 2];
|
||||
|
||||
for (int i = 0; i < old.Length; ++i)
|
||||
m_Keywords[i] = old[i];
|
||||
}
|
||||
|
||||
m_Keywords[Count++] = keyword;
|
||||
}
|
||||
|
||||
public int[] ToArray()
|
||||
{
|
||||
if (Count == 0)
|
||||
return m_EmptyInts;
|
||||
|
||||
int[] keywords = new int[Count];
|
||||
|
||||
for (int i = 0; i < Count; ++i)
|
||||
keywords[i] = m_Keywords[i];
|
||||
|
||||
Count = 0;
|
||||
|
||||
return keywords;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue