Skip to content

[FEATURE REQUEST] Make MedianOfRunningArray generic #4390

@vil02

Description

@vil02

What would you like to Propose?

I find it a bit odd that the MedianOfRunningArray only works with integers and returns double as the median. I suggest to make MedianOfRunningArray generic accepting any Number class.

Issue details

I suggest to define MedianOfRunningArray as

public class MedianOfRunningArray<T extends Number> {
    //...
}

and to change the method insert to accept objects of T and median to return T.

Additional Information

Please make sure to include the following test (rounding down to the integer):

var stream = new MedianOfRunningArray<Integer>();
stream.insert(1);
stream.insert(2);
assertEquals(1, stream.median());

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions