diff options
author | marha <marha@users.sourceforge.net> | 2012-11-19 10:38:33 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-11-19 10:38:33 +0100 |
commit | 24635abae6008bef13e30d798b3f33abab412770 (patch) | |
tree | e799fbde24e0fd935af76b0bc48d30ef69f75d54 /xorg-server/xkeyboard-config/tests/ruby/utils.rb | |
parent | e0844ae8b5ef87049537a7e0ebff81acc2695256 (diff) | |
parent | 6ce1d8f0f8c23e186175a7c84c21d7bfbe168dc5 (diff) | |
download | vcxsrv-24635abae6008bef13e30d798b3f33abab412770.tar.gz vcxsrv-24635abae6008bef13e30d798b3f33abab412770.tar.bz2 vcxsrv-24635abae6008bef13e30d798b3f33abab412770.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
Changed file permissions
dos -> unix
Conflicts:
libX11/include/X11/Xregion.h
libX11/src/ConvSel.c
libX11/src/CrGlCur.c
libX11/src/CrWindow.c
libX11/src/GetDflt.c
libX11/src/StrKeysym.c
libX11/src/Window.c
libX11/src/xkb/XKBBind.c
libX11/src/xkb/XKBGetMap.c
libX11/src/xkb/XKBSetGeom.c
libX11/src/xkb/XKBUse.c
libX11/src/xlibi18n/XimProto.h
libX11/src/xlibi18n/lcDynamic.c
libXdmcp/Key.c
libXdmcp/Write.c
libxcb/src/xcb_windefs.h
xkbcomp/keycodes.c
xkbcomp/xkbpath.c
xorg-server/hw/xwin/glx/winpriv.h
xorg-server/xkeyboard-config/rules/bin/ml1_s.sh
xorg-server/xkeyboard-config/rules/bin/ml1v1_s.sh
xorg-server/xkeyboard-config/rules/bin/ml1v_s.sh
xorg-server/xkeyboard-config/rules/bin/ml_s.sh
xorg-server/xkeyboard-config/rules/bin/mln_s.sh
xorg-server/xkeyboard-config/rules/bin/mlnvn_s.sh
xorg-server/xkeyboard-config/rules/bin/mlv_s.sh
xorg-server/xkeyboard-config/rules/compat/.gitignore
Diffstat (limited to 'xorg-server/xkeyboard-config/tests/ruby/utils.rb')
-rw-r--r-- | xorg-server/xkeyboard-config/tests/ruby/utils.rb | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/xorg-server/xkeyboard-config/tests/ruby/utils.rb b/xorg-server/xkeyboard-config/tests/ruby/utils.rb index 93ff0ee5e..3c699a7a8 100644 --- a/xorg-server/xkeyboard-config/tests/ruby/utils.rb +++ b/xorg-server/xkeyboard-config/tests/ruby/utils.rb @@ -1,64 +1,64 @@ -#
-# $Id$
-#
-# Commont classes
-#
-
-#
-# The hash containing non-unique mappings
-# It can have a->b and a->c together
-# Also, for every mapping it counts the number of times this mapping was set
-#
-class NonuniqueCountingHash < Hash
-
- alias get_original []
- alias put_original []=
-
- def []=(key, value)
- own = self.get_original(key)
- hash = get_original(key)
- if hash.nil?
- put_original(key, hash = Hash.new)
- end
- if hash.has_key?(value)
- hash[value] += 1
- else
- hash[value] = 1
- end
- end
-
- #
- # Number of all mappings (a->b and a->c counted as 2 mappings)
- #
- def full_length()
- values.inject(0) do | rv, hash |
- rv + hash.length
- end
- end
-
- def cardinality(key1, key2)
- if has_key?(key1)
- hash = get_original(key1)
- if hash.has_key?(key2)
- hash[key2]
- else
- 0
- end
- else
- 0
- end
- end
-
- def filter(limit)
- find_all do | key, hash |
- hash.find_all do | key1, counter |
- if (counter <= limit)
- hash.delete(key1)
- end
- end
- if hash.empty?
- delete(key)
- end
- end
- end
-end
+# +# $Id$ +# +# Commont classes +# + +# +# The hash containing non-unique mappings +# It can have a->b and a->c together +# Also, for every mapping it counts the number of times this mapping was set +# +class NonuniqueCountingHash < Hash + + alias get_original [] + alias put_original []= + + def []=(key, value) + own = self.get_original(key) + hash = get_original(key) + if hash.nil? + put_original(key, hash = Hash.new) + end + if hash.has_key?(value) + hash[value] += 1 + else + hash[value] = 1 + end + end + + # + # Number of all mappings (a->b and a->c counted as 2 mappings) + # + def full_length() + values.inject(0) do | rv, hash | + rv + hash.length + end + end + + def cardinality(key1, key2) + if has_key?(key1) + hash = get_original(key1) + if hash.has_key?(key2) + hash[key2] + else + 0 + end + else + 0 + end + end + + def filter(limit) + find_all do | key, hash | + hash.find_all do | key1, counter | + if (counter <= limit) + hash.delete(key1) + end + end + if hash.empty? + delete(key) + end + end + end +end |