2019-11-23 04:45:57 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright 2019 faddenSoft
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
using System;
|
2019-11-25 22:27:38 +00:00
|
|
|
|
using System.Collections;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace SourceGen {
|
2019-11-27 02:54:42 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Ordered list of visualization objects.
|
|
|
|
|
/// </summary>
|
2019-11-25 22:27:38 +00:00
|
|
|
|
public class VisualizationSet : IEnumerable<Visualization> {
|
|
|
|
|
/// <summary>
|
2019-11-27 02:54:42 +00:00
|
|
|
|
/// Object list.
|
2019-11-25 22:27:38 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
private List<Visualization> mList;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
|
2019-11-25 22:27:38 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructor.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cap">Initial capacity.</param>
|
|
|
|
|
public VisualizationSet(int cap = 1) {
|
|
|
|
|
mList = new List<Visualization>(cap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IEnumerable
|
|
|
|
|
public IEnumerator<Visualization> GetEnumerator() {
|
|
|
|
|
return mList.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// IEnumerable
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() {
|
|
|
|
|
return mList.GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of entries in the table.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Count {
|
|
|
|
|
get { return mList.Count; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(Visualization vis) {
|
|
|
|
|
mList.Add(vis);
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override string ToString() {
|
2019-11-25 22:27:38 +00:00
|
|
|
|
return "[VS: " + mList.Count + " items]";
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool operator ==(VisualizationSet a, VisualizationSet b) {
|
|
|
|
|
if (ReferenceEquals(a, b)) {
|
|
|
|
|
return true; // same object, or both null
|
|
|
|
|
}
|
|
|
|
|
if (ReferenceEquals(a, null) || ReferenceEquals(b, null)) {
|
|
|
|
|
return false; // one is null
|
|
|
|
|
}
|
|
|
|
|
// All fields must be equal.
|
2019-11-25 22:27:38 +00:00
|
|
|
|
if (a.mList.Count != b.mList.Count) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// Order matters.
|
|
|
|
|
for (int i = 0; i < a.mList.Count; i++) {
|
|
|
|
|
if (a.mList[i] != b.mList[i]) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
public static bool operator !=(VisualizationSet a, VisualizationSet b) {
|
|
|
|
|
return !(a == b);
|
|
|
|
|
}
|
|
|
|
|
public override bool Equals(object obj) {
|
|
|
|
|
return obj is VisualizationSet && this == (VisualizationSet)obj;
|
|
|
|
|
}
|
|
|
|
|
public override int GetHashCode() {
|
2019-11-25 22:27:38 +00:00
|
|
|
|
int hashCode = 0;
|
|
|
|
|
foreach (Visualization vis in mList) {
|
|
|
|
|
hashCode ^= vis.GetHashCode();
|
|
|
|
|
}
|
|
|
|
|
return hashCode;
|
2019-11-23 04:45:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|