Package org.drip.service.common
Class CollectionUtil
java.lang.Object
org.drip.service.common.CollectionUtil
public class CollectionUtil
extends java.lang.Object
CollectionUtil implements generic utility functions used in DROP modules. Some of the functions it
exposes are:
- Map Merging Functionality
- Map Key Functionality - key-value flatteners, key prefixers
- Decompose/transform List/Set/Array Contents
- Multi-Dimensional Map Manipulator Routines
- Construct n-derivatives array from Slope
- Collate Wengerts to a bigger Wengert
- Module = Computational Core Module
- Library = Numerical Analysis Library
- Project = Environment, Product/Definition Containers, and Scenario/State Manipulation APIs
- Package = Assorted Data Structures Support Utilities
- Author:
- Lakshmi Krishnamurthy
-
Constructor Summary
Constructors Constructor Description CollectionUtil()
-
Method Summary
Modifier and Type Method Description static WengertJacobian
AppendWengert(java.util.List<WengertJacobian> lsWJ)
Append the Wengert Jacobians inside the list onto one single compositestatic boolean
ContainsNearbyAlmostDuplicate(int[] numberArray, int k, int t)
Given an integer array numberArray and two integers k and t, return true if there are two distinct indices i and j in the array such that abs(numberArray[i] - numberArray[j]) .le.static double[]
DerivArrayFromSlope(int iNumDerivs, double dblSlope)
Populate an array of derivatives using the input slope (and setting the other to zero)static CaseInsensitiveTreeMap<java.lang.Double>
FlatStringTo2DSDMap(java.lang.String str2DMap, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter, boolean bSkipNullValue, java.lang.String strNULLString)
Turn a flattened 2D (string, double) string sequence into its corresponding mapstatic CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>>
FlatStringTo3DSDMap(java.lang.String str3DMap, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter, boolean bSkipNullValue, java.lang.String strNULLString)
Turn a flattened 3D (string, string, double) string sequence into its corresponding mapstatic CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>>>
FlatStringTo4DSDMap(java.lang.String str4DMap, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter, boolean bSkipNullValue, java.lang.String strNULLString)
Turn a flattened 4D (string, string, string, double) string sequence into its corresponding mapstatic java.lang.String
FourDSDMapToFlatString(CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>>> map4DSD, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter)
Flatten a 4D SSSD map structure onto a string arraystatic void
main(java.lang.String[] argumentArray)
Entry Pointstatic CaseInsensitiveTreeMap<java.lang.Double>
MergeMaps(CaseInsensitiveTreeMap<java.lang.Double> map1, CaseInsensitiveTreeMap<java.lang.Double> map2)
Merge two mapsstatic boolean
MergeWithMain(CaseInsensitiveTreeMap<java.lang.Double> mapMain, CaseInsensitiveTreeMap<java.lang.Double> mapToAdd)
Merge the secondary map onto the main mapstatic CaseInsensitiveTreeMap<java.lang.Double>
PrefixKeys(CaseInsensitiveTreeMap<java.lang.Double> mapIn, java.lang.String strPrefix)
Prefix the keys in the input map, and return them in a new mapstatic java.lang.String
ThreeDSDMapToFlatString(CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>> map3DSD, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter)
Flatten a 3D SSD map structure onto a string arraystatic java.lang.String
TwoDSDMapToFlatString(CaseInsensitiveTreeMap<java.lang.Double> map2DSD, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter)
Flatten an input 2D string/double map into a delimited string arrayMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CollectionUtil
public CollectionUtil()
-
-
Method Details
-
PrefixKeys
public static final CaseInsensitiveTreeMap<java.lang.Double> PrefixKeys(CaseInsensitiveTreeMap<java.lang.Double> mapIn, java.lang.String strPrefix)Prefix the keys in the input map, and return them in a new map- Parameters:
mapIn
- Input mapstrPrefix
- The prefix- Returns:
- Map containing the prefixed entries
-
MergeMaps
public static final CaseInsensitiveTreeMap<java.lang.Double> MergeMaps(CaseInsensitiveTreeMap<java.lang.Double> map1, CaseInsensitiveTreeMap<java.lang.Double> map2)Merge two maps- Parameters:
map1
- Map 1map2
- Map 2- Returns:
- The merged map
-
MergeWithMain
public static final boolean MergeWithMain(CaseInsensitiveTreeMap<java.lang.Double> mapMain, CaseInsensitiveTreeMap<java.lang.Double> mapToAdd)Merge the secondary map onto the main map- Parameters:
mapMain
- Main MapmapToAdd
- Secondary Map to Add- Returns:
- True - If successfully merged with main
-
TwoDSDMapToFlatString
public static final java.lang.String TwoDSDMapToFlatString(CaseInsensitiveTreeMap<java.lang.Double> map2DSD, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter)Flatten an input 2D string/double map into a delimited string array- Parameters:
map2DSD
- 2D String/Double mapstrKVDelimiter
- Element delimiterstrRecordDelimiter
- Record delimiter- Returns:
- Flattened map string
-
ThreeDSDMapToFlatString
public static final java.lang.String ThreeDSDMapToFlatString(CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>> map3DSD, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter)Flatten a 3D SSD map structure onto a string array- Parameters:
map3DSD
- 3D SSD mapstrMultiLevelKeyDelimiter
- Multi Level KeyDelimiterstrKVDelimiter
- Key-Value DelimiterstrRecordDelimiter
- Record Delimiter- Returns:
- Flattened String
-
FourDSDMapToFlatString
public static final java.lang.String FourDSDMapToFlatString(CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>>> map4DSD, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter)Flatten a 4D SSSD map structure onto a string array- Parameters:
map4DSD
- 4D SSSD mapstrMultiLevelKeyDelimiter
- Multi Level KeyDelimiterstrKVDelimiter
- Key-Value DelimiterstrRecordDelimiter
- Record Delimiter- Returns:
- Flattened String
-
FlatStringTo2DSDMap
public static final CaseInsensitiveTreeMap<java.lang.Double> FlatStringTo2DSDMap(java.lang.String str2DMap, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter, boolean bSkipNullValue, java.lang.String strNULLString)Turn a flattened 2D (string, double) string sequence into its corresponding map- Parameters:
str2DMap
- Flattened 2D array inputstrKVDelimiter
- Key-Value delimiter stringstrRecordDelimiter
- Record delimiter stringbSkipNullValue
- Indicates whether NULL Values are to be skippedstrNULLString
- NULL string- Returns:
- [String, double] map
-
FlatStringTo3DSDMap
public static final CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>> FlatStringTo3DSDMap(java.lang.String str3DMap, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter, boolean bSkipNullValue, java.lang.String strNULLString)Turn a flattened 3D (string, string, double) string sequence into its corresponding map- Parameters:
str3DMap
- Flattened 3D array inputstrMultiLevelKeyDelimiter
- Multi-level key delimiter stringstrKVDelimiter
- Key-Value delimiter stringstrRecordDelimiter
- Record delimiter stringbSkipNullValue
- Indicates whether NULL Values are to be skippedstrNULLString
- NULL string- Returns:
- [String, [String, double]] map
-
FlatStringTo4DSDMap
public static final CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<CaseInsensitiveTreeMap<java.lang.Double>>> FlatStringTo4DSDMap(java.lang.String str4DMap, java.lang.String strMultiLevelKeyDelimiter, java.lang.String strKVDelimiter, java.lang.String strRecordDelimiter, boolean bSkipNullValue, java.lang.String strNULLString)Turn a flattened 4D (string, string, string, double) string sequence into its corresponding map- Parameters:
str4DMap
- Flattened 4D array inputstrMultiLevelKeyDelimiter
- Multi-level key delimiter stringstrKVDelimiter
- Key-Value delimiter stringstrRecordDelimiter
- Record delimiter stringbSkipNullValue
- Indicates whether NULL Values are to be skippedstrNULLString
- NULL string- Returns:
- [String, [String, [String, double]]] map
-
DerivArrayFromSlope
public static final double[] DerivArrayFromSlope(int iNumDerivs, double dblSlope)Populate an array of derivatives using the input slope (and setting the other to zero)- Parameters:
iNumDerivs
- Number of Derivatives to be populateddblSlope
- Slope- Returns:
- Array of derivatives
-
AppendWengert
Append the Wengert Jacobians inside the list onto one single composite- Parameters:
lsWJ
- List of Wengert Jacobians- Returns:
- The Composite Wengert Jacobian
-
ContainsNearbyAlmostDuplicate
public static final boolean ContainsNearbyAlmostDuplicate(int[] numberArray, int k, int t)Given an integer array numberArray and two integers k and t, return true if there are two distinct indices i and j in the array such that abs(numberArray[i] - numberArray[j]) .le. t and abs(i - j) .le. k- Parameters:
numberArray
- Number Arrayk
- Kt
- T- Returns:
- TRUE - Element matching the criteria above found
-
main
public static final void main(java.lang.String[] argumentArray) throws java.lang.ExceptionEntry Point- Parameters:
argumentArray
- Argument Array- Throws:
java.lang.Exception
- Thrown if an Exception is encountered
-