Fusion.Engine.Common.AtomCollection.Add C# (CSharp) Method

Add() public method

public Add ( string atom ) : short
atom string
return short
		public short Add ( string atom )
		{
			lock (lockObj) {
				if (locked) {
					throw new InvalidOperationException("Atom collection is locked");
				}

				if (index.Count>=MaxAtomIndex) {
					throw new InvalidOperationException("Too much atoms");
				}

				if (dictionary.ContainsKey(atom)) {
					return dictionary[atom];
				}

				short id = (short)index.Count;
				index.Add( atom );
				dictionary.Add( atom, id );

				return id;
			}
		}