lipsync/trunk/bocoree/TreeMap.cs
kbinani 9de5d2e51e [trunk] (ry
git-svn-id: http://svn.sourceforge.jp/svnroot/lipsync@18 b1f601f4-4f45-0410-8980-aecacb008692
2010-03-17 03:14:08 +00:00

109 lines
2.5 KiB
C#

#if !JAVA
/*
* TreeMap.cs
* Copyright (c) 2009 kbinani
*
* This file is part of bocoree.
*
* bocoree is free software; you can redistribute it and/or
* modify it under the terms of the BSD License.
*
* bocoree is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
//#define DICTIONARY_TEST
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace bocoree {
[Serializable]
#if DICTIONARY_TEST
public class TreeMap<K, V> {
public V remove( Object key ) {
return default( V );
}
public Vector<K> keySet() {
return null;
}
public V get( K key ) {
return default( V );
}
public V put( K key, V value ) {
return default( V );
}
public bool containsKey( Object key ) {
return false;
}
public void clear() {
}
public int size() {
return 0;
}
}
#else
public class TreeMap<K, V> : Dictionary<K, V> {
public TreeMap()
: base() {
}
protected TreeMap( SerializationInfo info, StreamingContext context )
: base( info, context ) {
}
public V remove( Object key ) {
K k = (K)key;
if ( base.ContainsKey( k ) ) {
V old = base[k];
base.Remove( k );
return old;
} else {
base.Remove( k );
return default( V );
}
}
public Vector<K> keySet() {
return new Vector<K>( base.Keys );
}
public V get( K key ){
return base[key];
}
public int size(){
return base.Count;
}
public bool containsKey( Object key ) {
return base.ContainsKey( (K)key );
}
public void clear() {
base.Clear();
}
public V put( K key, V value ) {
if ( base.ContainsKey( key ) ){
V old = base[key];
base[key] = value;
return old;
} else {
base.Add( key, value );
return default( V );
}
}
}
#endif
}
#endif