Removed untyped contructor from ComponentRegistration and add a protected setter.
[castle.git] / Core / Castle.Core / Internal / GraphSets.cs
bloba5af9cdca6d4621e0fb774ee907970d9de0204f6
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle.Core.Internal
17 using System.Collections;
19 internal enum VertexColor
21 NotInThisSet,
22 /// <summary>
23 /// The node has not been visited yet
24 /// </summary>
25 White,
26 /// <summary>
27 /// This node is in the process of being visited
28 /// </summary>
29 Gray,
30 /// <summary>
31 /// This now was visited
32 /// </summary>
33 Black
36 /// <summary>
37 /// Represents a collection of objects
38 /// which are guaranted to be unique
39 /// and holds a color for them
40 /// </summary>
41 internal class ColorsSet
43 private Hashtable items = new Hashtable();
45 public ColorsSet(IVertex[] items)
47 foreach(IVertex item in items)
49 Set(item, VertexColor.White);
53 public void Set(IVertex item, VertexColor color)
55 items[item] = color;
58 public VertexColor ColorOf(IVertex item)
60 if (!items.ContainsKey(item)) return VertexColor.NotInThisSet;
61 return (VertexColor) items[item];
65 /// <summary>
66 /// Holds a timestamp (integer)
67 /// for a given item
68 /// </summary>
69 internal class TimestampSet
71 private Hashtable items = new Hashtable();
73 public TimestampSet()
77 public void Register(IVertex item, int time)
79 items[item] = time;
82 public int TimeOf(IVertex item)
84 return (int) items[item];